#line 1 "..\\app\\gt_alarm\\gt_alarm.c"



 
#line 1 "..\\app\\APP\\gtlib.h"








#line 1 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\string.h"
 
 
 
 




 








 












#line 38 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\string.h"


  
  typedef unsigned int size_t;








extern __declspec(__nothrow) void *memcpy(void * __restrict  ,
                    const void * __restrict  , size_t  ) __attribute__((__nonnull__(1,2)));
   




 
extern __declspec(__nothrow) void *memmove(void *  ,
                    const void *  , size_t  ) __attribute__((__nonnull__(1,2)));
   







 
extern __declspec(__nothrow) char *strcpy(char * __restrict  , const char * __restrict  ) __attribute__((__nonnull__(1,2)));
   




 
extern __declspec(__nothrow) char *strncpy(char * __restrict  , const char * __restrict  , size_t  ) __attribute__((__nonnull__(1,2)));
   





 

extern __declspec(__nothrow) char *strcat(char * __restrict  , const char * __restrict  ) __attribute__((__nonnull__(1,2)));
   




 
extern __declspec(__nothrow) char *strncat(char * __restrict  , const char * __restrict  , size_t  ) __attribute__((__nonnull__(1,2)));
   






 






 

extern __declspec(__nothrow) int memcmp(const void *  , const void *  , size_t  ) __attribute__((__nonnull__(1,2)));
   





 
extern __declspec(__nothrow) int strcmp(const char *  , const char *  ) __attribute__((__nonnull__(1,2)));
   




 
extern __declspec(__nothrow) int strncmp(const char *  , const char *  , size_t  ) __attribute__((__nonnull__(1,2)));
   






 
extern __declspec(__nothrow) int strcasecmp(const char *  , const char *  ) __attribute__((__nonnull__(1,2)));
   





 
extern __declspec(__nothrow) int strncasecmp(const char *  , const char *  , size_t  ) __attribute__((__nonnull__(1,2)));
   






 
extern __declspec(__nothrow) int strcoll(const char *  , const char *  ) __attribute__((__nonnull__(1,2)));
   







 

extern __declspec(__nothrow) size_t strxfrm(char * __restrict  , const char * __restrict  , size_t  ) __attribute__((__nonnull__(2)));
   













 


#line 185 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\string.h"
extern __declspec(__nothrow) void *memchr(const void *  , int  , size_t  ) __attribute__((__nonnull__(1)));

   





 

#line 201 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\string.h"
extern __declspec(__nothrow) char *strchr(const char *  , int  ) __attribute__((__nonnull__(1)));

   




 

extern __declspec(__nothrow) size_t strcspn(const char *  , const char *  ) __attribute__((__nonnull__(1,2)));
   




 

#line 224 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\string.h"
extern __declspec(__nothrow) char *strpbrk(const char *  , const char *  ) __attribute__((__nonnull__(1,2)));

   




 

#line 239 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\string.h"
extern __declspec(__nothrow) char *strrchr(const char *  , int  ) __attribute__((__nonnull__(1)));

   





 

extern __declspec(__nothrow) size_t strspn(const char *  , const char *  ) __attribute__((__nonnull__(1,2)));
   



 

#line 262 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\string.h"
extern __declspec(__nothrow) char *strstr(const char *  , const char *  ) __attribute__((__nonnull__(1,2)));

   





 

extern __declspec(__nothrow) char *strtok(char * __restrict  , const char * __restrict  ) __attribute__((__nonnull__(2)));
extern __declspec(__nothrow) char *_strtok_r(char *  , const char *  , char **  ) __attribute__((__nonnull__(2,3)));

extern __declspec(__nothrow) char *strtok_r(char *  , const char *  , char **  ) __attribute__((__nonnull__(2,3)));

   

































 

extern __declspec(__nothrow) void *memset(void *  , int  , size_t  ) __attribute__((__nonnull__(1)));
   



 
extern __declspec(__nothrow) char *strerror(int  );
   





 
extern __declspec(__nothrow) size_t strlen(const char *  ) __attribute__((__nonnull__(1)));
   



 

extern __declspec(__nothrow) size_t strlcpy(char *  , const char *  , size_t  ) __attribute__((__nonnull__(1,2)));
   
















 

extern __declspec(__nothrow) size_t strlcat(char *  , const char *  , size_t  ) __attribute__((__nonnull__(1,2)));
   






















 

extern __declspec(__nothrow) void _membitcpybl(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2)));
extern __declspec(__nothrow) void _membitcpybb(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2)));
extern __declspec(__nothrow) void _membitcpyhl(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2)));
extern __declspec(__nothrow) void _membitcpyhb(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2)));
extern __declspec(__nothrow) void _membitcpywl(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2)));
extern __declspec(__nothrow) void _membitcpywb(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2)));
extern __declspec(__nothrow) void _membitmovebl(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2)));
extern __declspec(__nothrow) void _membitmovebb(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2)));
extern __declspec(__nothrow) void _membitmovehl(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2)));
extern __declspec(__nothrow) void _membitmovehb(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2)));
extern __declspec(__nothrow) void _membitmovewl(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2)));
extern __declspec(__nothrow) void _membitmovewb(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2)));
    














































 







#line 494 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\string.h"



 

#line 10 "..\\app\\APP\\gtlib.h"
#line 1 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\stdlib.h"
 
 
 




 
 



 













  


 








#line 46 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\stdlib.h"


  
  typedef unsigned int size_t;










    



    typedef unsigned short wchar_t;  
#line 75 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\stdlib.h"

typedef struct div_t { int quot, rem; } div_t;
    
typedef struct ldiv_t { long int quot, rem; } ldiv_t;
    

typedef struct lldiv_t { __int64 quot, rem; } lldiv_t;
    


#line 96 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\stdlib.h"
   



 

   




 
#line 115 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\stdlib.h"
   


 
extern __declspec(__nothrow) int __aeabi_MB_CUR_MAX(void);

   




 

   




 




extern __declspec(__nothrow) double atof(const char *  ) __attribute__((__nonnull__(1)));
   



 
extern __declspec(__nothrow) int atoi(const char *  ) __attribute__((__nonnull__(1)));
   



 
extern __declspec(__nothrow) long int atol(const char *  ) __attribute__((__nonnull__(1)));
   



 

extern __declspec(__nothrow) __int64 atoll(const char *  ) __attribute__((__nonnull__(1)));
   



 


extern __declspec(__nothrow) double strtod(const char * __restrict  , char ** __restrict  ) __attribute__((__nonnull__(1)));
   

















 

extern __declspec(__nothrow) float strtof(const char * __restrict  , char ** __restrict  ) __attribute__((__nonnull__(1)));
extern __declspec(__nothrow) long double strtold(const char * __restrict  , char ** __restrict  ) __attribute__((__nonnull__(1)));
   

 

extern __declspec(__nothrow) long int strtol(const char * __restrict  ,
                        char ** __restrict  , int  ) __attribute__((__nonnull__(1)));
   



























 
extern __declspec(__nothrow) unsigned long int strtoul(const char * __restrict  ,
                                       char ** __restrict  , int  ) __attribute__((__nonnull__(1)));
   


























 

 
extern __declspec(__nothrow) __int64 strtoll(const char * __restrict  ,
                               char ** __restrict  , int  ) __attribute__((__nonnull__(1)));
   




 
extern __declspec(__nothrow) unsigned __int64 strtoull(const char * __restrict  ,
                                         char ** __restrict  , int  ) __attribute__((__nonnull__(1)));
   



 

extern __declspec(__nothrow) int rand(void);
   







 
extern __declspec(__nothrow) void srand(unsigned int  );
   






 

struct _rand_state { int __x[57]; };
extern __declspec(__nothrow) int _rand_r(struct _rand_state *);
extern __declspec(__nothrow) void _srand_r(struct _rand_state *, unsigned int);
struct _ANSI_rand_state { int __x[1]; };
extern __declspec(__nothrow) int _ANSI_rand_r(struct _ANSI_rand_state *);
extern __declspec(__nothrow) void _ANSI_srand_r(struct _ANSI_rand_state *, unsigned int);
   


 

extern __declspec(__nothrow) void *calloc(size_t  , size_t  );
   



 
extern __declspec(__nothrow) void free(void *  );
   





 
extern __declspec(__nothrow) void *malloc(size_t  );
   



 
extern __declspec(__nothrow) void *realloc(void *  , size_t  );
   













 

extern __declspec(__nothrow) int posix_memalign(void **  , size_t  , size_t  );
   









 

typedef int (*__heapprt)(void *, char const *, ...);
extern __declspec(__nothrow) void __heapstats(int (*  )(void *  ,
                                           char const *  , ...),
                        void *  ) __attribute__((__nonnull__(1)));
   










 
extern __declspec(__nothrow) int __heapvalid(int (*  )(void *  ,
                                           char const *  , ...),
                       void *  , int  ) __attribute__((__nonnull__(1)));
   














 
extern __declspec(__nothrow) __declspec(__noreturn) void abort(void);
   







 

extern __declspec(__nothrow) int atexit(void (*  )(void)) __attribute__((__nonnull__(1)));
   




 
#line 415 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\stdlib.h"


extern __declspec(__nothrow) __declspec(__noreturn) void exit(int  );
   












 

extern __declspec(__nothrow) __declspec(__noreturn) void _Exit(int  );
   







      

extern __declspec(__nothrow) char *getenv(const char *  ) __attribute__((__nonnull__(1)));
   









 

extern __declspec(__nothrow) int  system(const char *  );
   









 

extern  void *bsearch(const void *  , const void *  ,
              size_t  , size_t  ,
              int (*  )(const void *, const void *)) __attribute__((__nonnull__(1,2,5)));
   












 
#line 503 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\stdlib.h"


extern  void qsort(void *  , size_t  , size_t  ,
           int (*  )(const void *, const void *)) __attribute__((__nonnull__(1,4)));
   









 

#line 532 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\stdlib.h"

extern __declspec(__nothrow) __pure int abs(int  );
   



 

extern __declspec(__nothrow) __pure div_t div(int  , int  );
   









 
extern __declspec(__nothrow) __pure long int labs(long int  );
   



 




extern __declspec(__nothrow) __pure ldiv_t ldiv(long int  , long int  );
   











 







extern __declspec(__nothrow) __pure __int64 llabs(__int64  );
   



 




extern __declspec(__nothrow) __pure lldiv_t lldiv(__int64  , __int64  );
   











 
#line 613 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\stdlib.h"



 
typedef struct __sdiv32by16 { int quot, rem; } __sdiv32by16;
typedef struct __udiv32by16 { unsigned int quot, rem; } __udiv32by16;
    
typedef struct __sdiv64by32 { int rem, quot; } __sdiv64by32;

__value_in_regs extern __declspec(__nothrow) __pure __sdiv32by16 __rt_sdiv32by16(
     int  ,
     short int  );
   

 
__value_in_regs extern __declspec(__nothrow) __pure __udiv32by16 __rt_udiv32by16(
     unsigned int  ,
     unsigned short  );
   

 
__value_in_regs extern __declspec(__nothrow) __pure __sdiv64by32 __rt_sdiv64by32(
     int  , unsigned int  ,
     int  );
   

 



 
extern __declspec(__nothrow) unsigned int __fp_status(unsigned int  , unsigned int  );
   







 























 
extern __declspec(__nothrow) int mblen(const char *  , size_t  );
   












 
extern __declspec(__nothrow) int mbtowc(wchar_t * __restrict  ,
                   const char * __restrict  , size_t  );
   















 
extern __declspec(__nothrow) int wctomb(char *  , wchar_t  );
   













 





 
extern __declspec(__nothrow) size_t mbstowcs(wchar_t * __restrict  ,
                      const char * __restrict  , size_t  ) __attribute__((__nonnull__(2)));
   














 
extern __declspec(__nothrow) size_t wcstombs(char * __restrict  ,
                      const wchar_t * __restrict  , size_t  ) __attribute__((__nonnull__(2)));
   














 

extern __declspec(__nothrow) void __use_realtime_heap(void);
extern __declspec(__nothrow) void __use_realtime_division(void);
extern __declspec(__nothrow) void __use_two_region_memory(void);
extern __declspec(__nothrow) void __use_no_heap(void);
extern __declspec(__nothrow) void __use_no_heap_region(void);

extern __declspec(__nothrow) char const *__C_library_version_string(void);
extern __declspec(__nothrow) int __C_library_version_number(void);











#line 867 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\stdlib.h"


 

#line 11 "..\\app\\APP\\gtlib.h"
#line 1 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\stdio.h"
 
 
 





 






 













#line 38 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\stdio.h"


  
  typedef unsigned int size_t;    








 
 

 
  typedef struct __va_list __va_list;





   




 




typedef struct __fpos_t_struct {
    unsigned __int64 __pos;
    



 
    struct {
        unsigned int __state1, __state2;
    } __mbstate;
} fpos_t;
   


 


   

 

typedef struct __FILE FILE;
   






 

extern FILE __stdin, __stdout, __stderr;
extern FILE *__aeabi_stdin, *__aeabi_stdout, *__aeabi_stderr;

#line 129 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\stdio.h"
    

    

    





     



   


 


   


 

   



 

   


 




   


 





    


 






extern __declspec(__nothrow) int remove(const char *  ) __attribute__((__nonnull__(1)));
   





 
extern __declspec(__nothrow) int rename(const char *  , const char *  ) __attribute__((__nonnull__(1,2)));
   








 
extern __declspec(__nothrow) FILE *tmpfile(void);
   




 
extern __declspec(__nothrow) char *tmpnam(char *  );
   











 

extern __declspec(__nothrow) int fclose(FILE *  ) __attribute__((__nonnull__(1)));
   







 
extern __declspec(__nothrow) int fflush(FILE *  );
   







 
extern __declspec(__nothrow) FILE *fopen(const char * __restrict  ,
                           const char * __restrict  ) __attribute__((__nonnull__(1,2)));
   








































 
extern __declspec(__nothrow) FILE *freopen(const char * __restrict  ,
                    const char * __restrict  ,
                    FILE * __restrict  ) __attribute__((__nonnull__(2,3)));
   








 
extern __declspec(__nothrow) void setbuf(FILE * __restrict  ,
                    char * __restrict  ) __attribute__((__nonnull__(1)));
   




 
extern __declspec(__nothrow) int setvbuf(FILE * __restrict  ,
                   char * __restrict  ,
                   int  , size_t  ) __attribute__((__nonnull__(1)));
   















 
#pragma __printf_args
extern __declspec(__nothrow) int fprintf(FILE * __restrict  ,
                    const char * __restrict  , ...) __attribute__((__nonnull__(1,2)));
   


















 
#pragma __printf_args
extern __declspec(__nothrow) int _fprintf(FILE * __restrict  ,
                     const char * __restrict  , ...) __attribute__((__nonnull__(1,2)));
   



 
#pragma __printf_args
extern __declspec(__nothrow) int printf(const char * __restrict  , ...) __attribute__((__nonnull__(1)));
   




 
#pragma __printf_args
extern __declspec(__nothrow) int _printf(const char * __restrict  , ...) __attribute__((__nonnull__(1)));
   



 
#pragma __printf_args
extern __declspec(__nothrow) int sprintf(char * __restrict  , const char * __restrict  , ...) __attribute__((__nonnull__(1,2)));
   






 
#pragma __printf_args
extern __declspec(__nothrow) int _sprintf(char * __restrict  , const char * __restrict  , ...) __attribute__((__nonnull__(1,2)));
   



 

#pragma __printf_args
extern __declspec(__nothrow) int snprintf(char * __restrict  , size_t  ,
                     const char * __restrict  , ...) __attribute__((__nonnull__(3)));
   















 

#pragma __printf_args
extern __declspec(__nothrow) int _snprintf(char * __restrict  , size_t  ,
                      const char * __restrict  , ...) __attribute__((__nonnull__(3)));
   



 
#pragma __scanf_args
extern __declspec(__nothrow) int fscanf(FILE * __restrict  ,
                    const char * __restrict  , ...) __attribute__((__nonnull__(1,2)));
   






























 
#pragma __scanf_args
extern __declspec(__nothrow) int _fscanf(FILE * __restrict  ,
                     const char * __restrict  , ...) __attribute__((__nonnull__(1,2)));
   



 
#pragma __scanf_args
extern __declspec(__nothrow) int scanf(const char * __restrict  , ...) __attribute__((__nonnull__(1)));
   






 
#pragma __scanf_args
extern __declspec(__nothrow) int _scanf(const char * __restrict  , ...) __attribute__((__nonnull__(1)));
   



 
#pragma __scanf_args
extern __declspec(__nothrow) int sscanf(const char * __restrict  ,
                    const char * __restrict  , ...) __attribute__((__nonnull__(1,2)));
   








 
#pragma __scanf_args
extern __declspec(__nothrow) int _sscanf(const char * __restrict  ,
                     const char * __restrict  , ...) __attribute__((__nonnull__(1,2)));
   



 

 
extern __declspec(__nothrow) int vfscanf(FILE * __restrict  , const char * __restrict  , __va_list) __attribute__((__nonnull__(1,2)));
extern __declspec(__nothrow) int vscanf(const char * __restrict  , __va_list) __attribute__((__nonnull__(1)));
extern __declspec(__nothrow) int vsscanf(const char * __restrict  , const char * __restrict  , __va_list) __attribute__((__nonnull__(1,2)));

extern __declspec(__nothrow) int _vfscanf(FILE * __restrict  , const char * __restrict  , __va_list) __attribute__((__nonnull__(1,2)));
extern __declspec(__nothrow) int _vscanf(const char * __restrict  , __va_list) __attribute__((__nonnull__(1)));
extern __declspec(__nothrow) int _vsscanf(const char * __restrict  , const char * __restrict  , __va_list) __attribute__((__nonnull__(1,2)));

extern __declspec(__nothrow) int vprintf(const char * __restrict  , __va_list  ) __attribute__((__nonnull__(1)));
   





 
extern __declspec(__nothrow) int _vprintf(const char * __restrict  , __va_list  ) __attribute__((__nonnull__(1)));
   



 
extern __declspec(__nothrow) int vfprintf(FILE * __restrict  ,
                    const char * __restrict  , __va_list  ) __attribute__((__nonnull__(1,2)));
   






 
extern __declspec(__nothrow) int vsprintf(char * __restrict  ,
                     const char * __restrict  , __va_list  ) __attribute__((__nonnull__(1,2)));
   






 

extern __declspec(__nothrow) int vsnprintf(char * __restrict  , size_t  ,
                     const char * __restrict  , __va_list  ) __attribute__((__nonnull__(3)));
   







 

extern __declspec(__nothrow) int _vsprintf(char * __restrict  ,
                      const char * __restrict  , __va_list  ) __attribute__((__nonnull__(1,2)));
   



 
extern __declspec(__nothrow) int _vfprintf(FILE * __restrict  ,
                     const char * __restrict  , __va_list  ) __attribute__((__nonnull__(1,2)));
   



 
extern __declspec(__nothrow) int _vsnprintf(char * __restrict  , size_t  ,
                      const char * __restrict  , __va_list  ) __attribute__((__nonnull__(3)));
   



 
extern __declspec(__nothrow) int fgetc(FILE *  ) __attribute__((__nonnull__(1)));
   







 
extern __declspec(__nothrow) char *fgets(char * __restrict  , int  ,
                    FILE * __restrict  ) __attribute__((__nonnull__(1,3)));
   










 
extern __declspec(__nothrow) int fputc(int  , FILE *  ) __attribute__((__nonnull__(2)));
   







 
extern __declspec(__nothrow) int fputs(const char * __restrict  , FILE * __restrict  ) __attribute__((__nonnull__(1,2)));
   




 
extern __declspec(__nothrow) int getc(FILE *  ) __attribute__((__nonnull__(1)));
   







 




    extern __declspec(__nothrow) int (getchar)(void);

   





 
extern __declspec(__nothrow) char *gets(char *  ) __attribute__((__nonnull__(1)));
   









 
extern __declspec(__nothrow) int putc(int  , FILE *  ) __attribute__((__nonnull__(2)));
   





 




    extern __declspec(__nothrow) int (putchar)(int  );

   



 
extern __declspec(__nothrow) int puts(const char *  ) __attribute__((__nonnull__(1)));
   





 
extern __declspec(__nothrow) int ungetc(int  , FILE *  ) __attribute__((__nonnull__(2)));
   






















 

extern __declspec(__nothrow) size_t fread(void * __restrict  ,
                    size_t  , size_t  , FILE * __restrict  ) __attribute__((__nonnull__(1,4)));
   











 

extern __declspec(__nothrow) size_t __fread_bytes_avail(void * __restrict  ,
                    size_t  , FILE * __restrict  ) __attribute__((__nonnull__(1,3)));
   











 

extern __declspec(__nothrow) size_t fwrite(const void * __restrict  ,
                    size_t  , size_t  , FILE * __restrict  ) __attribute__((__nonnull__(1,4)));
   







 

extern __declspec(__nothrow) int fgetpos(FILE * __restrict  , fpos_t * __restrict  ) __attribute__((__nonnull__(1,2)));
   








 
extern __declspec(__nothrow) int fseek(FILE *  , long int  , int  ) __attribute__((__nonnull__(1)));
   














 
extern __declspec(__nothrow) int fsetpos(FILE * __restrict  , const fpos_t * __restrict  ) __attribute__((__nonnull__(1,2)));
   










 
extern __declspec(__nothrow) long int ftell(FILE *  ) __attribute__((__nonnull__(1)));
   











 
extern __declspec(__nothrow) void rewind(FILE *  ) __attribute__((__nonnull__(1)));
   





 

extern __declspec(__nothrow) void clearerr(FILE *  ) __attribute__((__nonnull__(1)));
   




 

extern __declspec(__nothrow) int feof(FILE *  ) __attribute__((__nonnull__(1)));
   


 
extern __declspec(__nothrow) int ferror(FILE *  ) __attribute__((__nonnull__(1)));
   


 
extern __declspec(__nothrow) void perror(const char *  );
   









 

extern __declspec(__nothrow) int _fisatty(FILE *   ) __attribute__((__nonnull__(1)));
    
 

extern __declspec(__nothrow) void __use_no_semihosting_swi(void);
extern __declspec(__nothrow) void __use_no_semihosting(void);
    





 











#line 948 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\stdio.h"



 

#line 12 "..\\app\\APP\\gtlib.h"
#line 1 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\time.h"
 
 
 
 









 





 













#line 41 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\time.h"


  
  typedef unsigned int size_t;








    
 
#line 65 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\time.h"





typedef unsigned int clock_t;     
typedef unsigned int time_t;      

#pragma push
#pragma anon_unions

struct tm {
    int tm_sec;   
 
    int tm_min;    
    int tm_hour;   
    int tm_mday;   
    int tm_mon;    
    int tm_year;   
    int tm_wday;   
    int tm_yday;   
    int tm_isdst;  
    union {        
        struct {
            int __extra_1, __extra_2;
        };
        struct {
            long __extra_1_long, __extra_2_long;
        };
        struct {
            char *__extra_1_cptr, *__extra_2_cptr;
        };
        struct {
            void *__extra_1_vptr, *__extra_2_vptr;
        };
    };
};

#pragma pop

   



 

extern __declspec(__nothrow) clock_t clock(void);
   





 
extern __declspec(__nothrow) double difftime(time_t  , time_t  );
   


 
extern __declspec(__nothrow) time_t mktime(struct tm *  ) __attribute__((__nonnull__(1)));
   













 
extern __declspec(__nothrow) time_t time(time_t *  );
   






 

extern __declspec(__nothrow) char *asctime(const struct tm *  ) __attribute__((__nonnull__(1)));
extern __declspec(__nothrow) char *_asctime_r(const struct tm *  ,
                                char * __restrict  ) __attribute__((__nonnull__(1,2)));

extern __declspec(__nothrow) char *asctime_r(const struct tm *  ,
                               char * __restrict  ) __attribute__((__nonnull__(1,2)));

   



 
extern __declspec(__nothrow) char *ctime(const time_t *  ) __attribute__((__nonnull__(1)));
   




 
extern __declspec(__nothrow) struct tm *gmtime(const time_t *  ) __attribute__((__nonnull__(1)));
   



 
extern __declspec(__nothrow) struct tm *localtime(const time_t *  ) __attribute__((__nonnull__(1)));
extern __declspec(__nothrow) struct tm *_localtime_r(const time_t * __restrict  ,
                                       struct tm * __restrict  ) __attribute__((__nonnull__(1,2)));

extern __declspec(__nothrow) struct tm *localtime_r(const time_t * __restrict  ,
                                      struct tm * __restrict  ) __attribute__((__nonnull__(1,2)));

   



 
extern __declspec(__nothrow) size_t strftime(char * __restrict  , size_t  ,
                       const char * __restrict  ,
                       const struct tm * __restrict  ) __attribute__((__nonnull__(1,3,4)));
   











































 











#line 272 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\time.h"



 

#line 13 "..\\app\\APP\\gtlib.h"
#line 1 "D:\\Keil\\ARM\\RV31\\INC\\rtl.h"









 




 

 



#line 28 "D:\\Keil\\ARM\\RV31\\INC\\rtl.h"







 typedef unsigned int   size_t;


typedef signed char     S8;
typedef unsigned char   U8;
typedef short           S16;
typedef unsigned short  U16;
typedef int             S32;
typedef unsigned int    U32;
typedef long long       S64;
typedef unsigned long long U64;
typedef unsigned char   BIT;
typedef unsigned int    BOOL;

#line 55 "D:\\Keil\\ARM\\RV31\\INC\\rtl.h"

#line 71 "D:\\Keil\\ARM\\RV31\\INC\\rtl.h"



 





 
typedef U32 OS_SEM[2];

 

typedef U32 OS_MBX[];

 
typedef U32 OS_MUT[3];

 
typedef U32 OS_TID;

 
typedef void *OS_ID;

 
typedef U32 OS_RESULT;

 












 




#line 202 "D:\\Keil\\ARM\\RV31\\INC\\rtl.h"



 



 
extern void      os_set_env    (void);
extern void      rt_sys_init   (void (*task)(void), U8 priority, void *stk);
extern void      rt_tsk_pass   (void);
extern OS_TID    rt_tsk_self   (void);
extern OS_RESULT rt_tsk_prio   (OS_TID task_id, U8 new_prio);
extern OS_TID    rt_tsk_create (void (*task)(void), U8 priority, void *stk, void *argv);
extern OS_RESULT rt_tsk_delete (OS_TID task_id);

#line 238 "D:\\Keil\\ARM\\RV31\\INC\\rtl.h"

extern void      _os_sys_init(U32 p, void (*task)(void), U32 prio_stksz,
                                     void *stk)                        __svc_indirect(0);
extern OS_TID    _os_tsk_create (U32 p, void (*task)(void), U32 prio_stksz,
                                        void *stk, void *argv)         __svc_indirect(0);
extern OS_TID    _os_tsk_create_ex (U32 p, void (*task)(void *), U32 prio_stksz,
                                           void *stk, void *argv)      __svc_indirect(0);
extern OS_TID    _os_tsk_self (U32 p)                                  __svc_indirect(0);
extern void      _os_tsk_pass (U32 p)                                  __svc_indirect(0);
extern OS_RESULT _os_tsk_prio (U32 p, OS_TID task_id, U8 new_prio)     __svc_indirect(0);
extern OS_RESULT _os_tsk_delete (U32 p, OS_TID task_id)                __svc_indirect(0);

 
extern OS_RESULT rt_evt_wait (U16 wait_flags,  U16 timeout, BOOL and_wait);
extern void      rt_evt_set  (U16 event_flags, OS_TID task_id);
extern void      rt_evt_clr  (U16 clear_flags, OS_TID task_id);
extern U16       rt_evt_get  (void);







extern OS_RESULT _os_evt_wait(U32 p, U16 wait_flags, U16 timeout,
                                     BOOL and_wait)                    __svc_indirect(0);
extern void      _os_evt_set (U32 p, U16 event_flags, OS_TID task_id)  __svc_indirect(0);
extern void      _os_evt_clr (U32 p, U16 clear_flags, OS_TID task_id)  __svc_indirect(0);
extern U16       _os_evt_get (U32 p)                                   __svc_indirect(0);
extern void      isr_evt_set (U16 event_flags, OS_TID task_id);

 
extern void      rt_sem_init (OS_ID semaphore, U16 token_count);
extern OS_RESULT rt_sem_send (OS_ID semaphore);
extern OS_RESULT rt_sem_wait (OS_ID semaphore, U16 timeout);





extern void      _os_sem_init (U32 p, OS_ID semaphore, 
                                      U16 token_count)                 __svc_indirect(0);
extern OS_RESULT _os_sem_send (U32 p, OS_ID semaphore)                 __svc_indirect(0);
extern OS_RESULT _os_sem_wait (U32 p, OS_ID semaphore, U16 timeout)    __svc_indirect(0);
extern void      isr_sem_send (OS_ID semaphore);

 
extern void      rt_mbx_init  (OS_ID mailbox, U16 mbx_size);
extern OS_RESULT rt_mbx_send  (OS_ID mailbox, void *p_msg,    U16 timeout);
extern OS_RESULT rt_mbx_wait  (OS_ID mailbox, void **message, U16 timeout);
extern OS_RESULT rt_mbx_check (OS_ID mailbox);







extern void      _os_mbx_init (U32 p, OS_ID mailbox, U16 mbx_size)     __svc_indirect(0);
extern OS_RESULT _os_mbx_send (U32 p, OS_ID mailbox, void *message_ptr,
                                      U16 timeout)                     __svc_indirect(0);
extern OS_RESULT _os_mbx_wait (U32 p, OS_ID mailbox, void  **message,
                                      U16 timeout)                     __svc_indirect(0);
extern OS_RESULT _os_mbx_check (U32 p, OS_ID mailbox)                  __svc_indirect(0);
extern void      isr_mbx_send (OS_ID mailbox, void *message_ptr);
extern OS_RESULT isr_mbx_receive (OS_ID mailbox, void **message);

 
extern void      rt_mut_init    (OS_ID mutex);
extern OS_RESULT rt_mut_release (OS_ID mutex);
extern OS_RESULT rt_mut_wait    (OS_ID mutex, U16 timeout);





extern void      _os_mut_init (U32 p, OS_ID mutex)                     __svc_indirect(0);
extern OS_RESULT _os_mut_release (U32 p, OS_ID mutex)                  __svc_indirect(0);
extern OS_RESULT _os_mut_wait (U32 p, OS_ID mutex, U16 timeout)        __svc_indirect(0);

 
extern U32       rt_time_get (void);
extern void      rt_dly_wait (U16 delay_time);
extern void      rt_itv_set  (U16 interval_time);
extern void      rt_itv_wait (void);






extern U32       _os_time_get (U32 p)                                  __svc_indirect(0);
extern void      _os_dly_wait (U32 p, U16 delay_time)                  __svc_indirect(0);
extern void      _os_itv_set (U32 p, U16 interval_time)                __svc_indirect(0);
extern void      _os_itv_wait (U32 p)                                  __svc_indirect(0);

 
extern OS_ID     rt_tmr_create (U16 tcnt, U16 info);
extern OS_ID     rt_tmr_kill   (OS_ID timer);




extern OS_ID     _os_tmr_create (U32 p, U16 tcnt, U16 info)            __svc_indirect(0);
extern OS_ID     _os_tmr_kill (U32 p, OS_ID timer)                     __svc_indirect(0);

 
extern U32       rt_suspend    (void);
extern void      rt_resume     (U32 sleep_time);
extern void      rt_tsk_lock   (void);
extern void      rt_tsk_unlock (void);






extern U32       _os_suspend (U32 p)                                   __svc_indirect(0);
extern void      _os_resume (U32 p, U32 sleep_time)                    __svc_indirect(0);
extern void      _os_tsk_lock (U32 p)                                  __svc_indirect(0);
extern void      _os_tsk_unlock (U32 p)                                __svc_indirect(0);

 
extern int       _init_box (void *box_mem, U32 box_size, U32 blk_size);
extern void     *_alloc_box (void *box_mem);
extern void     *_calloc_box (void *box_mem);
extern int       _free_box (void *box_mem, void *box);








 




 

typedef struct {                         
  U8  hr;                                
  U8  min;                               
  U8  sec;                               
  U8  day;                               
  U8  mon;                               
  U16 year;                              
} RL_TIME;

typedef struct {                         
  S8  name[256];                         
  U32 size;                              
  U16 fileID;                            
  U8  attrib;                            
  RL_TIME time;                          
} FINFO;

extern int finit (const char *drive);
extern int funinit (const char *drive);
extern int fdelete (const char *filename);
extern int frename (const char *oldname, const char *newname);
extern int ffind (const char *pattern, FINFO *info);
extern U64 ffree (const char *drive);
extern int fformat (const char *drive);
extern int fanalyse (const char *drive);
extern int fcheck (const char *drive);
extern int fdefrag (const char *drive);
extern int fattrib (const char *par, const char *path);
extern int fvol    (const char *drive, char *buf);

 




 

 



 
#line 428 "D:\\Keil\\ARM\\RV31\\INC\\rtl.h"

 
#line 436 "D:\\Keil\\ARM\\RV31\\INC\\rtl.h"

 
#line 449 "D:\\Keil\\ARM\\RV31\\INC\\rtl.h"

 




 




 



 



 



 
#line 484 "D:\\Keil\\ARM\\RV31\\INC\\rtl.h"

 



 





 



 





 
#line 512 "D:\\Keil\\ARM\\RV31\\INC\\rtl.h"

 




 
#line 527 "D:\\Keil\\ARM\\RV31\\INC\\rtl.h"

 
#line 537 "D:\\Keil\\ARM\\RV31\\INC\\rtl.h"

 
#line 545 "D:\\Keil\\ARM\\RV31\\INC\\rtl.h"

 



 
typedef struct sockaddr {          
  U16  sa_family;                  
  char sa_data[14];                
} SOCKADDR;

#pragma push
#pragma anon_unions

typedef struct in_addr {           
  union {
    struct {
      U8 s_b1,s_b2,s_b3,s_b4;      
    };
    struct {
      U16 s_w1,s_w2;               
    };
    U32 s_addr;                    
  };
} IN_ADDR;
#pragma pop

typedef struct sockaddr_in {       
  S16 sin_family;                  
  U16 sin_port;                    
  IN_ADDR sin_addr;                
  S8  sin_zero[8];                 
} SOCKADDR_IN;

typedef struct hostent {           
  char *h_name;                    
  char **h_aliases;                
  S16  h_addrtype;                 
  S16  h_length;                   
  char **h_addr_list;              
} HOSTENT;

extern void init_TcpNet (void);
extern BOOL main_TcpNet (void);
extern void timer_tick (void);
extern U8   udp_get_socket (U8 tos, U8 opt, 
                            U16 (*listener)(U8 socket, U8 *remip, U16 port, U8 *buf, U16 len));
extern BOOL udp_release_socket (U8 socket);
extern BOOL udp_open (U8 socket, U16 locport);
extern BOOL udp_close (U8 socket);
extern BOOL udp_mcast_ttl (U8 socket, U8 ttl);
extern U8  *udp_get_buf (U16 size);
extern BOOL udp_send (U8 socket, U8 *remip, U16 remport, U8 *buf, U16 dlen);
extern U8   tcp_get_socket (U8 type, U8 tos, U16 tout,
                            U16 (*listener)(U8 socket, U8 event, U8 *buf, U16 len));
extern BOOL tcp_release_socket (U8 socket);
extern BOOL tcp_listen (U8 socket, U16 locport);
extern BOOL tcp_connect (U8 socket, U8 *remip, U16 remport, U16 locport);
extern U8  *tcp_get_buf (U16 size);
extern U16  tcp_max_dsize (U8 socket);
extern BOOL tcp_check_send (U8 socket);
extern U8   tcp_get_state (U8 socket);
extern BOOL tcp_send (U8 socket, U8 *buf, U16 dlen);
extern BOOL tcp_close (U8 socket);
extern BOOL tcp_abort (U8 socket);
extern void tcp_reset_window (U8 socket);
extern BOOL arp_cache_ip (U8 *ipadr, U8 type);
extern BOOL arp_cache_mac (U8 *hwadr);
extern void ppp_listen (const char *user, const char *passw);
extern void ppp_connect (const char *dialnum, const char *user, const char *passw);
extern void ppp_close (void);
extern BOOL ppp_is_up (void);
extern void slip_listen (void);
extern void slip_connect (const char *dialnum);
extern void slip_close (void);
extern BOOL slip_is_up (void);
extern U8   get_host_by_name (U8 *hostn, void (*cbfunc)(U8 event, U8 *host_ip));
extern BOOL smtp_connect (U8 *ipadr, U16 port, void (*cbfunc)(U8 event));
extern void dhcp_disable (void);
extern BOOL igmp_join (U8 *group_ip);
extern BOOL igmp_leave (U8 *group_ip);
extern BOOL snmp_trap (U8 *manager_ip, U8 gen_trap, U8 spec_trap, U16 *obj_list);
extern BOOL snmp_set_community (const char *community);
extern BOOL icmp_ping (U8 *remip, void (*cbfunc)(U8 event));
extern BOOL ftpc_connect (U8 *ipadr, U16 port, U8 command, void (*cbfunc)(U8 event));
extern BOOL tftpc_put (U8 *ipadr, U16 port,
                       const char *src, const char *dst, void (*cbfunc)(U8 event));
extern BOOL tftpc_get (U8 *ipadr, U16 port, 
                       const char *src, const char *dst, void (*cbfunc)(U8 event));
extern BOOL sntp_get_time (U8 *ipadr, void (*cbfunc)(U32 utc_time));

 
extern int  socket (int family, int type, int protocol);
extern int  bind (int sock, const SOCKADDR *addr, int addrlen);
extern int  listen (int sock, int backlog);
extern int  accept (int sock, SOCKADDR *addr, int *addrlen);
extern int  connect (int sock, SOCKADDR *addr, int addrlen);
extern int  send (int sock, const char *buf, int len, int flags);
extern int  sendto (int sock, const char *buf, int len, int flags, SOCKADDR *to, int tolen);
extern int  recv (int sock, char *buf, int len, int flags);
extern int  recvfrom (int sock, char *buf, int len, int flags, SOCKADDR *from, int *fromlen);
extern int  closesocket (int sock);
extern int  getpeername (int sock, SOCKADDR *name, int *namelen);
extern int  getsockname (int sock, SOCKADDR *name, int *namelen);
extern int  ioctlsocket (int sock, long cmd, unsigned long *argp);
extern HOSTENT *gethostbyname (const char *name, int *err);







 


 
#line 14 "..\\app\\APP\\gtlib.h"
#line 1 "..\\config\\Net_Config.h"









 




#line 16 "..\\config\\Net_Config.h"

 



                                   






 






 




 
#line 53 "..\\config\\Net_Config.h"

 





 
#line 84 "..\\config\\Net_Config.h"

 





typedef struct os_frame {          
  U16 length;                      
  U16 index;                       
  U8  data[1];                     
} OS_FRAME;

typedef struct arp_info {          
  U8  State;                       
  U8  Type;                        
  U8  Retries;                     
  U8  Tout;                        
  U8  HwAdr[6];           
  U8  IpAdr[4];            
} ARP_INFO;

typedef struct igmp_info {         
  U8  State;                       
  U8  Tout;                        
  U8  Flags;                       
  U8  GrpIpAdr[4];         
} IGMP_INFO;

typedef struct udp_info {          
  U8  State;                       
  U8  Opt;                         
  U8  Flags;                       
  U8  Tos;                         
  U16 LocPort;                     
  U8  McastTtl;                    
                                   
  U16 (*cb_func)(U8 socket, U8 *rem_ip, U16 port, U8 *buf, U16 len);
} UDP_INFO;

typedef struct tcp_info {          
  U8  State;                       
  U8  Type;                        
  U8  Flags;                       
  U8  Tos;                         
  U8  RemIpAdr[4];         
  U16 RemPort;                     
  U16 LocPort;                     
  U16 MaxSegSize;                  
  U16 Tout;                        
  U16 AliveTimer;                  
  U16 RetryTimer;                  
  U8  AckTimer;                    
  U8  Id;                          
  U8  Retries;                     
  U8  DupAcks;                     
  U32 SendUna;                     
  U32 SendNext;                    
  U32 SendChk;                     
  U32 SendWl1;                     
  U32 SendWl2;                     
  U16 SendWin;                     
  S16 RttSa;                       
  S16 RttSv;                       
  U16 CWnd;                        
  U16 SsThresh;                    
  U16 RecWin;                      
  U32 RecNext;                     
  OS_FRAME *unack_list;            
                                   
  U16 (*cb_func)(U8 socket, U8 event, U8 *p1, U16 p2);
} TCP_INFO;

typedef struct bsd_info {          
  U8  State;                       
  U8  Socket;                      
  U8  Flags;                       
  U8  Type;                        
  U16 LocPort;                     
  U16 RemPort;                     
  U32 LocIP;                       
  U32 RemIP;                       
  U8  AcceptSock;                  
  U8  ParentSock;                  
  U8  Event;                       
  U8  Task;                        
  U16 Tout;                        
  void *buf_list;                  
} BSD_INFO;

typedef struct http_info {         
  U8  State;                       
  U8  Socket;                      
  U16 Flags;                       
  U8  FType;                       
  U8  PostSt;                      
  U16 DelimSz;                     
  U8  UserId;                      
  U32 CGIvar;                      
  U32 DLen;                        
  U32 Count;                       
  U16 BCnt;                        
  U8  Lang[6];                     
  U32 LMDate;                      
  U8 *Script;                      
  U8 *pDelim;                      
  void *sFile;                     
  void *dFile;                     
} HTTP_INFO;

typedef struct http_file {         
  U32       Id;                    
  const U8 *Start;                 
} const HTTP_FILE;

typedef struct tnet_info {         
  U8  State;                       
  U8  Socket;                      
  U8  Flags;                       
  U8  BCnt;                        
  U16 Tout;                        
  U8  UserId;                      
  U8  Widx;                        
  U8  Ridx;                        
  U8  hNext;                       
  U8  hCurr;                       
  U32 SVar;                        
  U8  LBuf[96];           
  U8  Fifo[128];           
  U8  Hist[128];           
} TNET_INFO;

typedef struct tftp_info {         
  U8  State;                       
  U8  Socket;                      
  U8  Flags;                       
  U8  Retries;                     
  U8  RemIpAdr[4];         
  U16 RemPort;                     
  U16 BlockSz;                     
  U16 BlockNr;                     
  U8  Timer;                       
  U16 BufLen;                      
  U8  *Buf;                        
  void *File;                      
} TFTP_INFO;

typedef struct ftp_info {          
  U8  State;                       
  U8  Socket;                      
  U16 Flags;                       
  U8  RemIpAdr[4];         
  U16 DPort;                       
  U8  DSocket;                     
  U8  UserId;                      
  U8  Resp;                        
  U8  PathLen;                     
  U8 *Path;                        
  U8 *Name;                        
  void *File;                      
} FTP_INFO;

typedef struct dns_cache {         
  U32 HostId;                      
  U32 Ttl;                         
  U8  IpAdr[4];            
} DNS_CACHE;

typedef struct localm {            
  U8  IpAdr[4];            
  U8  DefGW[4];            
  U8  NetMask[4];          
  U8  PriDNS[4];           
  U8  SecDNS[4];           
} LOCALM;

typedef struct remotem {           
  U8  IpAdr[4];            
  U8  HwAdr[6];           
} REMOTEM;

typedef struct mib_entry {         
  U8  Type;                        
  U8  OidLen;                      
  U8  Oid[17];              
  U8  ValSz;                       
  void *Val;                       
  void (*cb_func)(int mode);       
} MIB_ENTRY;

typedef struct sys_cfg {           
  U32 *MemPool;                    
  U32 MemSize;                     
  U8  TickRate;                    
  U8  TickItv;                     
  U8  T200ms;                      
  U8  NetCfg;                      
  U8 *HostName;                    
} const SYS_CFG;

typedef struct arp_cfg {           
  ARP_INFO *Table;                 
  U8  TabSize;                     
  U8  TimeOut;                     
  U8  MaxRetry;                    
  U8  Resend;                      
  U8  Notify;                      
} const ARP_CFG;

typedef struct igmp_cfg {          
  IGMP_INFO *Table;                
  U16 TabSize;                     
} const IGMP_CFG;

typedef struct dhcp_cfg {          
  U8 *Vcid;                        
  U8  Opt;                         
} const DHCP_CFG;

typedef struct ppp_cfg {           
  U32 ACCmap;                      
  U16 SerTout;                     
  U16 RetryTout;                   
  U16 EchoTout;                    
  U8  MaxRetry;                    
  U8  EnAuth;                      
} const PPP_CFG;

typedef struct udp_cfg {           
  UDP_INFO *Scb;                   
  U8  NumSocks;                    
} const UDP_CFG;

typedef struct tcp_cfg {           
  TCP_INFO *Scb;                   
  U8  NumSocks;                    
  U8  MaxRetry;                    
  U16 RetryTout;                   
  U16 T2MSLTout;                   
  U16 SynRetryTout;                
  U16 InitRetryTout;               
  U16 DefTout;                     
  U16 MaxSegSize;                  
  U16 RecWinSize;                  
  U8  ConRetry;                    
} const TCP_CFG;

typedef struct http_cfg {          
  HTTP_INFO *Scb;                  
  U8  NumSess;                     
  U8  EnAuth;                      
  U16 PortNum;                     
  U8 const *SrvId;                 
  U8 const *Realm;                 
  U8 const *User;                  
  U8 *Passw;                       
} const HTTP_CFG;

typedef struct tnet_cfg {          
  TNET_INFO *Scb;                  
  U8  NumSess;                     
  U8  EnAuth;                      
  U8  NoEcho;                      
  U16 PortNum;                     
  U16 IdleTout;                    
  U8 const *User;                  
  U8 *Passw;                       
} const TNET_CFG;

typedef struct tftp_cfg {          
  TFTP_INFO *Scb;                  
  U8  NumSess;                     
  U8  MaxRetry;                    
  U16 PortNum;                     
  U8  DefTout;                     
  U8  EnFwall;                     
} const TFTP_CFG;

typedef struct tftpc_cfg {         
  U16 BlockSize;                   
  U16 RetryTout;                   
  U8  MaxRetry;                    
} const TFTPC_CFG;

typedef struct ftp_cfg {           
  FTP_INFO *Scb;                   
  U8  NumSess;                     
  U8  EnAuth;                      
  U16 PortNum;                     
  U16 IdleTout;                    
  U8  MsgLen;                      
  U8 const *Msg;                    
  U8 const *User;                  
  U8 *Passw;                       
} const FTP_CFG;

typedef struct ftpc_cfg {          
  U8  DefTout;                     
  U8  PasvMode;                    
} const FTPC_CFG;

typedef struct dns_cfg {           
  DNS_CACHE *Table;                
  U8  TabSize;                     
} const DNS_CFG;

typedef struct snmp_cfg {          
  U16 PortNum;                     
  U16 TrapPort;                    
  U8  TrapIp[4];           
  U8 const *Community;             
  U8  TickItv;                     
} const SNMP_CFG;

typedef struct sntp_cfg {          
  U8  SrvIp[4];            
  U8  Bcast;                       
} const SNTP_CFG;

typedef struct bsd_cfg {           
  BSD_INFO *Scb;                   
  U8  NumSocks;                    
  U8  InRtx;                       
  U16 RcvTout;                     
} const BSD_CFG;

typedef enum {                     
  ERR_MEM_ALLOC,                   
  ERR_MEM_FREE,                    
  ERR_MEM_CORRUPT,                 
  ERR_MEM_LOCK,                    
  ERR_UDP_ALLOC,                   
  ERR_TCP_ALLOC,                   
  ERR_TCP_STATE                    
} ERROR_CODE;




 

 
extern void init_system (void);
extern void run_system (void);
extern void sys_error (ERROR_CODE code);

 
extern OS_FRAME *alloc_mem (U32 byte_size);
extern void free_mem (OS_FRAME *mem_ptr);

 
extern void eth_init_link (void);
extern void eth_run_link (void);
extern void put_in_queue (OS_FRAME *frame);
extern BOOL eth_send_frame (OS_FRAME *frame);
extern BOOL eth_chk_adr (OS_FRAME *frame);
extern U8  *eth_get_adr (U8 *ipadr);

 
extern void ppp_init_link (void);
extern void ppp_run_link (void);
extern BOOL ppp_send_frame (OS_FRAME *frame, U16 prot);

 
extern void pap_init (void);
extern void pap_process (OS_FRAME *frame);
extern void pap_run (void);

 
extern void chap_init (void);
extern void chap_process (OS_FRAME *frame);
extern void chap_run (void);

 
extern void slip_init_link (void);
extern void slip_run_link (void);
extern BOOL slip_send_frame (OS_FRAME *frame);

 
extern int  mem_copy (void *dp, void *sp, int len);
extern void mem_rcopy (void *dp, void *sp, int len);
extern BOOL mem_comp (void *sp1, void *sp2, int len);
extern void mem_set (void *dp, U8 val, int len);
extern BOOL mem_test (void *sp, U8 val, int len);
extern BOOL str_scomp (U8 *sp, U8 const *cp);
extern int  str_copy (U8 *dp, U8 *sp);
extern void str_up_case (U8 *dp, U8 *sp);

 
extern void arp_notify (void);
extern BOOL arp_get_info (REMOTEM *info);

 
extern void ip_init (void);
extern void ip_run_local (void);

 
extern void dhcp_cbfunc (U8 opt, U8 *val);

 
extern void icmp_init (void);
extern void icmp_run_engine (void);

 
extern void igmp_init (void);
extern void igmp_run_host (void);
extern void igmp_process (OS_FRAME *frame);

 
extern void udp_init (void);
extern void udp_process (OS_FRAME *frame);

 
extern void tcp_init (void);
extern void tcp_poll_sockets (void);
extern void tcp_process (OS_FRAME *frame);

 
extern void bsd_init (void);
extern void bsd_poll_sockets (void);
extern U8   bsd_wait (BSD_INFO *bsd_s, U8 evt);
extern void bsd_enable (BSD_INFO *bsd_s, U8 evt);

 
extern void bsd_init_host (void);

 
extern void http_init (void);
extern void http_run_server (void);
extern void *http_fopen (U8 *name);
extern void http_fclose (void *file);
extern U16  http_fread (void *file, U8 *buf, U16 len);
extern BOOL http_fgets (void *file, U8 *buf, U16 size);
extern U32  http_finfo (U8 *name);
extern void cgi_process_var (U8 *qstr);
extern void cgi_process_data (U8 code, U8 *dat, U16 len);
extern U16  cgi_func (U8 *env, U8 *buf, U16 buflen, U32 *pcgi);
extern U8  *cgx_content_type (void);
extern BOOL http_accept_host (U8 *rem_ip, U16 rem_port);
extern BOOL http_file_access (U8 *fname, U8 user_id);
extern U8   http_check_account (U8 *user, U8 *passw);
extern U8  *http_get_var (U8 *env, void *ansi, U16 maxlen);
extern U8  *http_get_lang (void);
extern void http_get_info (REMOTEM *info);
extern U8   http_get_session (void);
extern U8   http_get_user_id (void);
extern U8  *http_get_content_type (void);
extern U32  http_date (RL_TIME *time);

 
extern void tnet_init (void);
extern void tnet_run_server (void);
extern U16  tnet_cbfunc (U8 code, U8 *buf, U16 buflen);
extern U16  tnet_process_cmd (U8 *cmd, U8 *buf, U16 buflen, U32 *pvar);
extern BOOL tnet_ccmp (U8 *buf, U8 *cmd);
extern void tnet_set_delay (U16 cnt);
extern void tnet_get_info (REMOTEM *info);
extern U8   tnet_get_session (void);
extern U8   tnet_get_user_id (void);
extern BOOL tnet_msg_poll (U8 session);
extern BOOL tnet_accept_host (U8 *rem_ip, U16 rem_port);
extern U8   tnet_check_account (U8 code, U8 *id);

 
extern void tftp_init (void);
extern void tftp_run_server (void);
extern void *tftp_fopen (U8 *fname, U8 *mode);
extern void tftp_fclose (void *file);
extern U16  tftp_fread (void *file, U8 *buf, U16 len);
extern U16  tftp_fwrite (void *file, U8 *buf, U16 len);
extern BOOL tftp_accept_host (U8 *rem_ip, U16 rem_port);

 
extern void tftpc_init (void);
extern void tftpc_run_client (void);
extern void *tftpc_fopen (U8 *fname, U8 *mode);
extern void tftpc_fclose (void *file);
extern U16  tftpc_fread (void *file, U8 *buf, U16 len);
extern U16  tftpc_fwrite (void *file, U8 *buf, U16 len);

 
extern void ftp_init (void);
extern void ftp_run_server (void);
extern void *ftp_fopen (U8 *fname, U8 *mode);
extern void ftp_fclose (void *file);
extern U16  ftp_fread (void *file, U8 *buf, U16 len);
extern U16  ftp_fwrite (void *file, U8 *buf, U16 len);
extern BOOL ftp_fdelete (U8 *fname);
extern BOOL ftp_frename (U8 *fname, U8 *newn);
extern U16  ftp_ffind (U8 code, U8 *buf, U8 *mask, U16 len);
extern BOOL ftp_accept_host (U8 *rem_ip, U16 rem_port);
extern U8   ftp_check_account (U8 code, U8 *id);
extern U8   ftp_get_user_id (void);
extern BOOL ftp_file_access (U8 *fname, U8 mode, U8 user_id);

 
extern void ftpc_init (void);
extern void ftpc_run_client (void);
extern void *ftpc_fopen (U8 *mode);
extern void ftpc_fclose (void *file);
extern U16  ftpc_fread (void *file, U8 *buf, U16 len);
extern U16  ftpc_fwrite (void *file, U8 *buf, U16 len);
extern U16  ftpc_cbfunc (U8 code, U8 *buf, U16 buflen);

 
extern void dhcp_init (void);
extern void dhcp_run_client (void);


 
extern void nbns_init (void);

 
extern void dns_init (void);
extern void dns_run_client (void);
extern U8   get_host_by_name (U8 *hostn, void (*cbfunc)(U8, U8 *));

 
extern void smtp_init (void);
extern void smtp_run_client (void);
extern U16  smtp_cbfunc (U8 code, U8 *buf, U16 buflen, U32 *pvar);
extern BOOL smtp_accept_auth (U8 *srv_ip);

 
extern void snmp_init (void);
extern void snmp_run_agent (void);

 
extern void sntp_init (void);
extern void sntp_run_client (void);

 
extern void init_ethernet (void);
extern void send_frame (OS_FRAME *frame);
__weak void poll_ethernet (void);
extern void int_enable_eth (void);
extern void int_disable_eth (void);

 
extern void init_serial (void);
extern int  com_getchar (void);
extern BOOL com_putchar (U8 c);
extern BOOL com_tx_active (void);

 
extern void modem_init (void);
extern void modem_dial (U8 *dialnum);
extern void modem_hangup (void);
extern void modem_listen (void);
extern BOOL modem_online (void);
extern BOOL modem_process (U8 ch);
extern void modem_run (void);







 



#line 15 "..\\app\\APP\\gtlib.h"

typedef unsigned char   uint8;
typedef unsigned short  uint16;
typedef unsigned int    uint32;
typedef unsigned long long uint64;

typedef unsigned char   U8;
typedef unsigned short  U16;
typedef unsigned int    U32;
typedef unsigned long long U64;

typedef unsigned char BYTE;



void bitSet(uint32* dat,int pos);
void bitClr(uint32* dat,int pos);
int	 bitTest(uint32* dat,int pos);
int  bitCnt(uint32* dat,int len);



U16 CHECK_CRC(const U8 *p,U16 n);
uint16 calc_crc(uint8 dat,uint16 crc);

U16 cs16(const U8 *p, U32 nLength);
U8 cs8(const U8 *p, U32 nLength);



void   memreverse(uint8* pBuf,int size); 
uint8  bcd2bin8 (uint8  x);
uint8  bin2bcd8 (uint8  x);
uint16 bin2bcd16(uint16 x);
uint16 bcd2bin16(uint16 x);
uint32 bin2bcd32(uint32 x);
uint32 bcd2bin32(uint32 x);
uint64 bin2bcd64(uint64 x);
uint64 bcd2bin64(uint64 x);





































int set_time(unsigned int t);
int set_time_bcd(unsigned char *Bcd6Time);
void time2bcd(time_t t,U8 * btime);
time_t bcd2time(U8 * bTime,U8 n);
int dif_time(U8 *btime,U8 type);
int ot_time(U8 type,int dif);
int next_time_bcd(U8 *next, U8 *cur,U8 type);

extern void Sleep(int ms);

extern uint32 debugMark;

#line 111 "..\\app\\APP\\gtlib.h"












 
#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"














 

 



 
#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_map.h"














 

 







 
#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_conf.h"













 

 



 
#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_type.h"














 

 



 
 
typedef signed long  s32;
typedef signed short s16;
typedef signed char  s8;

typedef signed long  const sc32;   
typedef signed short const sc16;   
typedef signed char  const sc8;    

typedef volatile signed long  vs32;
typedef volatile signed short vs16;
typedef volatile signed char  vs8;

typedef volatile signed long  const vsc32;   
typedef volatile signed short const vsc16;   
typedef volatile signed char  const vsc8;    

typedef unsigned long  u32;
typedef unsigned short u16;
typedef unsigned char  u8;

typedef unsigned long  const uc32;   
typedef unsigned short const uc16;   
typedef unsigned char  const uc8;    

typedef volatile unsigned long  vu32;
typedef volatile unsigned short vu16;
typedef volatile unsigned char  vu8;

typedef volatile unsigned long  const vuc32;   
typedef volatile unsigned short const vuc16;   
typedef volatile unsigned char  const vuc8;    



typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;

typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;


typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;

#line 73 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_type.h"

 
 
 



 
#line 22 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_conf.h"

 
 


 
 

 
 





 


 


 


 


 


 
#line 66 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_conf.h"

 


 



 


 


 
#line 90 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_conf.h"

 




 


 


 


 


 


 


 





 


 
#line 133 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_conf.h"

 
#line 141 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_conf.h"

 



 


 
#line 167 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_conf.h"



 
#line 27 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_map.h"
#line 28 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_map.h"
#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\cortexm3_macro.h"













 

 



 
#line 22 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\cortexm3_macro.h"

 
 
 
 
void __WFI(void);
void __WFE(void);
void __SEV(void);
void __ISB(void);
void __DSB(void);
void __DMB(void);
void __SVC(void);
u32 __MRS_CONTROL(void);
void __MSR_CONTROL(u32 Control);
u32 __MRS_PSP(void);
void __MSR_PSP(u32 TopOfProcessStack);
u32 __MRS_MSP(void);
void __MSR_MSP(u32 TopOfMainStack);
void __RESETPRIMASK(void);
void __SETPRIMASK(void);
u32 __READ_PRIMASK(void);
void __RESETFAULTMASK(void);
void __SETFAULTMASK(void);
u32 __READ_FAULTMASK(void);
void __BASEPRICONFIG(u32 NewPriority);
u32 __GetBASEPRI(void);
u16 __REV_HalfWord(u16 Data);
u32 __REV_Word(u32 Data);



 
#line 29 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_map.h"

 
 
 
 

 
typedef struct
{
  vu32 SR;
  vu32 CR1;
  vu32 CR2;
  vu32 SMPR1;
  vu32 SMPR2;
  vu32 JOFR1;
  vu32 JOFR2;
  vu32 JOFR3;
  vu32 JOFR4;
  vu32 HTR;
  vu32 LTR;
  vu32 SQR1;
  vu32 SQR2;
  vu32 SQR3;
  vu32 JSQR;
  vu32 JDR1;
  vu32 JDR2;
  vu32 JDR3;
  vu32 JDR4;
  vu32 DR;
} ADC_TypeDef;

 
typedef struct
{
  u32  RESERVED0;
  vu16 DR1;
  u16  RESERVED1;
  vu16 DR2;
  u16  RESERVED2;
  vu16 DR3;
  u16  RESERVED3;
  vu16 DR4;
  u16  RESERVED4;
  vu16 DR5;
  u16  RESERVED5;
  vu16 DR6;
  u16  RESERVED6;
  vu16 DR7;
  u16  RESERVED7;
  vu16 DR8;
  u16  RESERVED8;
  vu16 DR9;
  u16  RESERVED9;
  vu16 DR10;
  u16  RESERVED10; 
  vu16 RTCCR;
  u16  RESERVED11;
  vu16 CR;
  u16  RESERVED12;
  vu16 CSR;
  u16  RESERVED13[5];
  vu16 DR11;
  u16  RESERVED14;
  vu16 DR12;
  u16  RESERVED15;
  vu16 DR13;
  u16  RESERVED16;
  vu16 DR14;
  u16  RESERVED17;
  vu16 DR15;
  u16  RESERVED18;
  vu16 DR16;
  u16  RESERVED19;
  vu16 DR17;
  u16  RESERVED20;
  vu16 DR18;
  u16  RESERVED21;
  vu16 DR19;
  u16  RESERVED22;
  vu16 DR20;
  u16  RESERVED23;
  vu16 DR21;
  u16  RESERVED24;
  vu16 DR22;
  u16  RESERVED25;
  vu16 DR23;
  u16  RESERVED26;
  vu16 DR24;
  u16  RESERVED27;
  vu16 DR25;
  u16  RESERVED28;
  vu16 DR26;
  u16  RESERVED29;
  vu16 DR27;
  u16  RESERVED30;
  vu16 DR28;
  u16  RESERVED31;
  vu16 DR29;
  u16  RESERVED32;
  vu16 DR30;
  u16  RESERVED33; 
  vu16 DR31;
  u16  RESERVED34;
  vu16 DR32;
  u16  RESERVED35;
  vu16 DR33;
  u16  RESERVED36;
  vu16 DR34;
  u16  RESERVED37;
  vu16 DR35;
  u16  RESERVED38;
  vu16 DR36;
  u16  RESERVED39;
  vu16 DR37;
  u16  RESERVED40;
  vu16 DR38;
  u16  RESERVED41;
  vu16 DR39;
  u16  RESERVED42;
  vu16 DR40;
  u16  RESERVED43;
  vu16 DR41;
  u16  RESERVED44;
  vu16 DR42;
  u16  RESERVED45;    
} BKP_TypeDef;

 
typedef struct
{
  vu32 TIR;
  vu32 TDTR;
  vu32 TDLR;
  vu32 TDHR;
} CAN_TxMailBox_TypeDef;

typedef struct
{
  vu32 RIR;
  vu32 RDTR;
  vu32 RDLR;
  vu32 RDHR;
} CAN_FIFOMailBox_TypeDef;

typedef struct
{
  vu32 FR1;
  vu32 FR2;
} CAN_FilterRegister_TypeDef;

typedef struct
{
  vu32 MCR;
  vu32 MSR;
  vu32 TSR;
  vu32 RF0R;
  vu32 RF1R;
  vu32 IER;
  vu32 ESR;
  vu32 BTR;
  u32  RESERVED0[88];
  CAN_TxMailBox_TypeDef sTxMailBox[3];
  CAN_FIFOMailBox_TypeDef sFIFOMailBox[2];
  u32  RESERVED1[12];
  vu32 FMR;
  vu32 FM1R;
  u32  RESERVED2;
  vu32 FS1R;
  u32  RESERVED3;
  vu32 FFA1R;
  u32  RESERVED4;
  vu32 FA1R;
  u32  RESERVED5[8];
  CAN_FilterRegister_TypeDef sFilterRegister[14];
} CAN_TypeDef;

 
typedef struct
{
  vu32 DR;
  vu8  IDR;
  u8   RESERVED0;
  u16  RESERVED1;
  vu32 CR;
} CRC_TypeDef;


 
typedef struct
{
  vu32 CR;
  vu32 SWTRIGR;
  vu32 DHR12R1;
  vu32 DHR12L1;
  vu32 DHR8R1;
  vu32 DHR12R2;
  vu32 DHR12L2;
  vu32 DHR8R2;
  vu32 DHR12RD;
  vu32 DHR12LD;
  vu32 DHR8RD;
  vu32 DOR1;
  vu32 DOR2;
} DAC_TypeDef;

 
typedef struct
{
  vu32 IDCODE;
  vu32 CR;	
}DBGMCU_TypeDef;

 
typedef struct
{
  vu32 CCR;
  vu32 CNDTR;
  vu32 CPAR;
  vu32 CMAR;
} DMA_Channel_TypeDef;

typedef struct
{
  vu32 ISR;
  vu32 IFCR;
} DMA_TypeDef;

 
typedef struct
{
  vu32 IMR;
  vu32 EMR;
  vu32 RTSR;
  vu32 FTSR;
  vu32 SWIER;
  vu32 PR;
} EXTI_TypeDef;

 
typedef struct
{
  vu32 ACR;
  vu32 KEYR;
  vu32 OPTKEYR;
  vu32 SR;
  vu32 CR;
  vu32 AR;
  vu32 RESERVED;
  vu32 OBR;
  vu32 WRPR;
} FLASH_TypeDef;

typedef struct
{
  vu16 RDP;
  vu16 USER;
  vu16 Data0;
  vu16 Data1;
  vu16 WRP0;
  vu16 WRP1;
  vu16 WRP2;
  vu16 WRP3;
} OB_TypeDef;

 
typedef struct
{
  vu32 BTCR[8];   
} FSMC_Bank1_TypeDef; 

typedef struct
{
  vu32 BWTR[7];
} FSMC_Bank1E_TypeDef;

typedef struct
{
  vu32 PCR2;
  vu32 SR2;
  vu32 PMEM2;
  vu32 PATT2;
  u32  RESERVED0;   
  vu32 ECCR2; 
} FSMC_Bank2_TypeDef;  

typedef struct
{
  vu32 PCR3;
  vu32 SR3;
  vu32 PMEM3;
  vu32 PATT3;
  u32  RESERVED0;   
  vu32 ECCR3; 
} FSMC_Bank3_TypeDef; 

typedef struct
{
  vu32 PCR4;
  vu32 SR4;
  vu32 PMEM4;
  vu32 PATT4;
  vu32 PIO4; 
} FSMC_Bank4_TypeDef; 

 
typedef struct
{
  vu32 CRL;
  vu32 CRH;
  vu32 IDR;
  vu32 ODR;
  vu32 BSRR;
  vu32 BRR;
  vu32 LCKR;
} GPIO_TypeDef;

typedef struct
{
  vu32 EVCR;
  vu32 MAPR;
  vu32 EXTICR[4];
} AFIO_TypeDef;

 
typedef struct
{
  vu16 CR1;
  u16  RESERVED0;
  vu16 CR2;
  u16  RESERVED1;
  vu16 OAR1;
  u16  RESERVED2;
  vu16 OAR2;
  u16  RESERVED3;
  vu16 DR;
  u16  RESERVED4;
  vu16 SR1;
  u16  RESERVED5;
  vu16 SR2;
  u16  RESERVED6;
  vu16 CCR;
  u16  RESERVED7;
  vu16 TRISE;
  u16  RESERVED8;
} I2C_TypeDef;

 
typedef struct
{
  vu32 KR;
  vu32 PR;
  vu32 RLR;
  vu32 SR;
} IWDG_TypeDef;

 
typedef struct
{
  vu32 ISER[2];
  u32  RESERVED0[30];
  vu32 ICER[2];
  u32  RSERVED1[30];
  vu32 ISPR[2];
  u32  RESERVED2[30];
  vu32 ICPR[2];
  u32  RESERVED3[30];
  vu32 IABR[2];
  u32  RESERVED4[62];
  vu32 IPR[15];
} NVIC_TypeDef;

typedef struct
{
  vuc32 CPUID;
  vu32 ICSR;
  vu32 VTOR;
  vu32 AIRCR;
  vu32 SCR;
  vu32 CCR;
  vu32 SHPR[3];
  vu32 SHCSR;
  vu32 CFSR;
  vu32 HFSR;
  vu32 DFSR;
  vu32 MMFAR;
  vu32 BFAR;
  vu32 AFSR;
} SCB_TypeDef;

 
typedef struct
{
  vu32 CR;
  vu32 CSR;
} PWR_TypeDef;

 
typedef struct
{
  vu32 CR;
  vu32 CFGR;
  vu32 CIR;
  vu32 APB2RSTR;
  vu32 APB1RSTR;
  vu32 AHBENR;
  vu32 APB2ENR;
  vu32 APB1ENR;
  vu32 BDCR;
  vu32 CSR;
} RCC_TypeDef;

 
typedef struct
{
  vu16 CRH;
  u16  RESERVED0;
  vu16 CRL;
  u16  RESERVED1;
  vu16 PRLH;
  u16  RESERVED2;
  vu16 PRLL;
  u16  RESERVED3;
  vu16 DIVH;
  u16  RESERVED4;
  vu16 DIVL;
  u16  RESERVED5;
  vu16 CNTH;
  u16  RESERVED6;
  vu16 CNTL;
  u16  RESERVED7;
  vu16 ALRH;
  u16  RESERVED8;
  vu16 ALRL;
  u16  RESERVED9;
} RTC_TypeDef;

 
typedef struct
{
  vu32 POWER;
  vu32 CLKCR;
  vu32 ARG;
  vu32 CMD;
  vuc32 RESPCMD;
  vuc32 RESP1;
  vuc32 RESP2;
  vuc32 RESP3;
  vuc32 RESP4;
  vu32 DTIMER;
  vu32 DLEN;
  vu32 DCTRL;
  vuc32 DCOUNT;
  vuc32 STA;
  vu32 ICR;
  vu32 MASK;
  u32  RESERVED0[2];
  vuc32 FIFOCNT;
  u32  RESERVED1[13];
  vu32 FIFO;
} SDIO_TypeDef;

 
typedef struct
{
  vu16 CR1;
  u16  RESERVED0;
  vu16 CR2;
  u16  RESERVED1;
  vu16 SR;
  u16  RESERVED2;
  vu16 DR;
  u16  RESERVED3;
  vu16 CRCPR;
  u16  RESERVED4;
  vu16 RXCRCR;
  u16  RESERVED5;
  vu16 TXCRCR;
  u16  RESERVED6;
  vu16 I2SCFGR;
  u16  RESERVED7;
  vu16 I2SPR;
  u16  RESERVED8;  
} SPI_TypeDef;

 
typedef struct
{
  vu32 CTRL;
  vu32 LOAD;
  vu32 VAL;
  vuc32 CALIB;
} SysTick_TypeDef;

 
typedef struct
{
  vu16 CR1;
  u16  RESERVED0;
  vu16 CR2;
  u16  RESERVED1;
  vu16 SMCR;
  u16  RESERVED2;
  vu16 DIER;
  u16  RESERVED3;
  vu16 SR;
  u16  RESERVED4;
  vu16 EGR;
  u16  RESERVED5;
  vu16 CCMR1;
  u16  RESERVED6;
  vu16 CCMR2;
  u16  RESERVED7;
  vu16 CCER;
  u16  RESERVED8;
  vu16 CNT;
  u16  RESERVED9;
  vu16 PSC;
  u16  RESERVED10;
  vu16 ARR;
  u16  RESERVED11;
  vu16 RCR;
  u16  RESERVED12;
  vu16 CCR1;
  u16  RESERVED13;
  vu16 CCR2;
  u16  RESERVED14;
  vu16 CCR3;
  u16  RESERVED15;
  vu16 CCR4;
  u16  RESERVED16;
  vu16 BDTR;
  u16  RESERVED17;
  vu16 DCR;
  u16  RESERVED18;
  vu16 DMAR;
  u16  RESERVED19;
} TIM_TypeDef;

 
typedef struct
{
  vu16 SR;
  u16  RESERVED0;
  vu16 DR;
  u16  RESERVED1;
  vu16 BRR;
  u16  RESERVED2;
  vu16 CR1;
  u16  RESERVED3;
  vu16 CR2;
  u16  RESERVED4;
  vu16 CR3;
  u16  RESERVED5;
  vu16 GTPR;
  u16  RESERVED6;
} USART_TypeDef;

 
typedef struct
{
  vu32 CR;
  vu32 CFR;
  vu32 SR;
} WWDG_TypeDef;

 
 
 
 



 



 


 




#line 634 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_map.h"

#line 651 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_map.h"



#line 670 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_map.h"

 

 


 






 


 






 
 
 

 



























































































































































































































#line 924 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_map.h"














 
#line 1180 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_map.h"

 
 
 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"

#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_adc.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_adc.h"

 
 
typedef struct
{
  u32 ADC_Mode;
  FunctionalState ADC_ScanConvMode; 
  FunctionalState ADC_ContinuousConvMode;
  u32 ADC_ExternalTrigConv;
  u32 ADC_DataAlign;
  u8 ADC_NbrOfChannel;
}ADC_InitTypeDef;

 



                                 



 
#line 55 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_adc.h"

#line 66 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_adc.h"

 
 
#line 75 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_adc.h"
 


 
#line 85 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_adc.h"

#line 100 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_adc.h"

 






 
#line 127 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_adc.h"

#line 137 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_adc.h"

 
#line 147 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_adc.h"

#line 156 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_adc.h"

 
 





 



 






#line 188 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_adc.h"

 










 
#line 208 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_adc.h"

#line 216 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_adc.h"

 








 











 


 


 


 


 


 


 


 
 
void ADC_DeInit(ADC_TypeDef* ADCx);
void ADC_Init(ADC_TypeDef* ADCx, ADC_InitTypeDef* ADC_InitStruct);
void ADC_StructInit(ADC_InitTypeDef* ADC_InitStruct);
void ADC_Cmd(ADC_TypeDef* ADCx, FunctionalState NewState);
void ADC_DMACmd(ADC_TypeDef* ADCx, FunctionalState NewState);
void ADC_ITConfig(ADC_TypeDef* ADCx, u16 ADC_IT, FunctionalState NewState);
void ADC_ResetCalibration(ADC_TypeDef* ADCx);
FlagStatus ADC_GetResetCalibrationStatus(ADC_TypeDef* ADCx);
void ADC_StartCalibration(ADC_TypeDef* ADCx);
FlagStatus ADC_GetCalibrationStatus(ADC_TypeDef* ADCx);
void ADC_SoftwareStartConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
FlagStatus ADC_GetSoftwareStartConvStatus(ADC_TypeDef* ADCx);
void ADC_DiscModeChannelCountConfig(ADC_TypeDef* ADCx, u8 Number);
void ADC_DiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
void ADC_RegularChannelConfig(ADC_TypeDef* ADCx, u8 ADC_Channel, u8 Rank, u8 ADC_SampleTime);
void ADC_ExternalTrigConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
u16 ADC_GetConversionValue(ADC_TypeDef* ADCx);
u32 ADC_GetDualModeConversionValue(void);
void ADC_AutoInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
void ADC_InjectedDiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
void ADC_ExternalTrigInjectedConvConfig(ADC_TypeDef* ADCx, u32 ADC_ExternalTrigInjecConv);
void ADC_ExternalTrigInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
void ADC_SoftwareStartInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
FlagStatus ADC_GetSoftwareStartInjectedConvCmdStatus(ADC_TypeDef* ADCx);
void ADC_InjectedChannelConfig(ADC_TypeDef* ADCx, u8 ADC_Channel, u8 Rank, u8 ADC_SampleTime);
void ADC_InjectedSequencerLengthConfig(ADC_TypeDef* ADCx, u8 Length);
void ADC_SetInjectedOffset(ADC_TypeDef* ADCx, u8 ADC_InjectedChannel, u16 Offset);
u16 ADC_GetInjectedConversionValue(ADC_TypeDef* ADCx, u8 ADC_InjectedChannel);
void ADC_AnalogWatchdogCmd(ADC_TypeDef* ADCx, u32 ADC_AnalogWatchdog);
void ADC_AnalogWatchdogThresholdsConfig(ADC_TypeDef* ADCx, u16 HighThreshold, u16 LowThreshold);
void ADC_AnalogWatchdogSingleChannelConfig(ADC_TypeDef* ADCx, u8 ADC_Channel);
void ADC_TempSensorVrefintCmd(FunctionalState NewState);
FlagStatus ADC_GetFlagStatus(ADC_TypeDef* ADCx, u8 ADC_FLAG);
void ADC_ClearFlag(ADC_TypeDef* ADCx, u8 ADC_FLAG);
ITStatus ADC_GetITStatus(ADC_TypeDef* ADCx, u16 ADC_IT);
void ADC_ClearITPendingBit(ADC_TypeDef* ADCx, u16 ADC_IT);



 
#line 26 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_bkp.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_bkp.h"

 
 
 






 










 
#line 87 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_bkp.h"

#line 102 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_bkp.h"



 
 
void BKP_DeInit(void);
void BKP_TamperPinLevelConfig(u16 BKP_TamperPinLevel);
void BKP_TamperPinCmd(FunctionalState NewState);
void BKP_ITConfig(FunctionalState NewState);
void BKP_RTCOutputConfig(u16 BKP_RTCOutputSource);
void BKP_SetRTCCalibrationValue(u8 CalibrationValue);
void BKP_WriteBackupRegister(u16 BKP_DR, u16 Data);
u16 BKP_ReadBackupRegister(u16 BKP_DR);
FlagStatus BKP_GetFlagStatus(void);
void BKP_ClearFlag(void);
ITStatus BKP_GetITStatus(void);
void BKP_ClearITPendingBit(void);



 
#line 30 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_can.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_can.h"

 
 
typedef struct
{
  FunctionalState CAN_TTCM;
  FunctionalState CAN_ABOM;
  FunctionalState CAN_AWUM;
  FunctionalState CAN_NART;
  FunctionalState CAN_RFLM;
  FunctionalState CAN_TXFP;
  u8 CAN_Mode;
  u8 CAN_SJW;
  u8 CAN_BS1;
  u8 CAN_BS2;
  u16 CAN_Prescaler;
} CAN_InitTypeDef;

 
typedef struct
{
  u8 CAN_FilterNumber;
  u8 CAN_FilterMode;
  u8 CAN_FilterScale;
  u16 CAN_FilterIdHigh;
  u16 CAN_FilterIdLow;
  u16 CAN_FilterMaskIdHigh;
  u16 CAN_FilterMaskIdLow;
  u16 CAN_FilterFIFOAssignment;
  FunctionalState CAN_FilterActivation;
} CAN_FilterInitTypeDef;

 
typedef struct
{
  u32 StdId;
  u32 ExtId;
  u8 IDE;
  u8 RTR;
  u8 DLC;
  u8 Data[8];
} CanTxMsg;

 
typedef struct
{
  u32 StdId;
  u32 ExtId;
  u8 IDE;
  u8 RTR;
  u8 DLC;
  u8 Data[8];
  u8 FMI;
} CanRxMsg;

 

 



 








 








 
#line 119 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_can.h"



 
#line 131 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_can.h"



 


 


 






 






 






 





 





 





 





 





 



 



 







 
#line 225 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_can.h"

#line 233 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_can.h"

#line 240 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_can.h"

 
 
void CAN_DeInit(void);
u8 CAN_Init(CAN_InitTypeDef* CAN_InitStruct);
void CAN_FilterInit(CAN_FilterInitTypeDef* CAN_FilterInitStruct);
void CAN_StructInit(CAN_InitTypeDef* CAN_InitStruct);
void CAN_ITConfig(u32 CAN_IT, FunctionalState NewState);
u8 CAN_Transmit(CanTxMsg* TxMessage);
u8 CAN_TransmitStatus(u8 TransmitMailbox);
void CAN_CancelTransmit(u8 Mailbox);
void CAN_FIFORelease(u8 FIFONumber);
u8 CAN_MessagePending(u8 FIFONumber);
void CAN_Receive(u8 FIFONumber, CanRxMsg* RxMessage);
u8 CAN_Sleep(void);
u8 CAN_WakeUp(void);
FlagStatus CAN_GetFlagStatus(u32 CAN_FLAG);
void CAN_ClearFlag(u32 CAN_FLAG);
ITStatus CAN_GetITStatus(u32 CAN_IT);
void CAN_ClearITPendingBit(u32 CAN_IT);



 
#line 34 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_crc.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_crc.h"

 
 
 
 
void CRC_ResetDR(void);
u32 CRC_CalcCRC(u32 Data);
u32 CRC_CalcBlockCRC(u32 pBuffer[], u32 BufferLength);
u32 CRC_GetCRC(void);
void CRC_SetIDRegister(u8 IDValue);
u8 CRC_GetIDRegister(void);



 
#line 38 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_dac.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_dac.h"

 
 
typedef struct
{
  u32 DAC_Trigger;
  u32 DAC_WaveGeneration;
  u32 DAC_LFSRUnmask_TriangleAmplitude;
  u32 DAC_OutputBuffer; 
}DAC_InitTypeDef;

 
 
#line 45 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_dac.h"

#line 55 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_dac.h"

 








 
#line 78 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_dac.h"

#line 91 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_dac.h"

#line 116 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_dac.h"

 






 






 








 






 


 
 
void DAC_DeInit(void);
void DAC_Init(u32 DAC_Channel, DAC_InitTypeDef* DAC_InitStruct);
void DAC_StructInit(DAC_InitTypeDef* DAC_InitStruct);
void DAC_Cmd(u32 DAC_Channel, FunctionalState NewState);
void DAC_DMACmd(u32 DAC_Channel, FunctionalState NewState);
void DAC_SoftwareTriggerCmd(u32 DAC_Channel, FunctionalState NewState);
void DAC_DualSoftwareTriggerCmd(FunctionalState NewState);
void DAC_WaveGenerationCmd(u32 DAC_Channel, u32 DAC_Wave, FunctionalState NewState);
void DAC_SetChannel1Data(u32 DAC_Align, u16 Data);
void DAC_SetChannel2Data(u32 DAC_Align, u16 Data);
void DAC_SetDualChannelData(u32 DAC_Align, u16 Data2, u16 Data1);
u16 DAC_GetDataOutputValue(u32 DAC_Channel);



 
#line 42 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_dbgmcu.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_dbgmcu.h"

 
 
#line 42 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_dbgmcu.h"
                                           


 
 
u32 DBGMCU_GetREVID(void);
u32 DBGMCU_GetDEVID(void);
void DBGMCU_Config(u32 DBGMCU_Periph, FunctionalState NewState);



 


#line 46 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_dma.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_dma.h"

 
 
typedef struct
{
  u32 DMA_PeripheralBaseAddr;
  u32 DMA_MemoryBaseAddr;
  u32 DMA_DIR;
  u32 DMA_BufferSize;
  u32 DMA_PeripheralInc;
  u32 DMA_MemoryInc;
  u32 DMA_PeripheralDataSize;
  u32 DMA_MemoryDataSize;
  u32 DMA_Mode;
  u32 DMA_Priority;
  u32 DMA_M2M;
}DMA_InitTypeDef;

 
#line 54 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_dma.h"

 






 






 






 








 








 





 










 





 






 
#line 153 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_dma.h"
 
#line 174 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_dma.h"

#line 200 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_dma.h"

 
 
#line 231 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_dma.h"
 
#line 252 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_dma.h"

#line 278 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_dma.h"

 


 
 
void DMA_DeInit(DMA_Channel_TypeDef* DMAy_Channelx);
void DMA_Init(DMA_Channel_TypeDef* DMAy_Channelx, DMA_InitTypeDef* DMA_InitStruct);
void DMA_StructInit(DMA_InitTypeDef* DMA_InitStruct);
void DMA_Cmd(DMA_Channel_TypeDef* DMAy_Channelx, FunctionalState NewState);
void DMA_ITConfig(DMA_Channel_TypeDef* DMAy_Channelx, u32 DMA_IT, FunctionalState NewState);
u16 DMA_GetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx);
FlagStatus DMA_GetFlagStatus(u32 DMA_FLAG);
void DMA_ClearFlag(u32 DMA_FLAG);
ITStatus DMA_GetITStatus(u32 DMA_IT);
void DMA_ClearITPendingBit(u32 DMA_IT);



 
#line 50 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_exti.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_exti.h"

 
 
typedef enum
{
  EXTI_Mode_Interrupt = 0x00,
  EXTI_Mode_Event = 0x04
}EXTIMode_TypeDef;


                            
 
typedef enum
{
  EXTI_Trigger_Rising = 0x08,
  EXTI_Trigger_Falling = 0x0C,  
  EXTI_Trigger_Rising_Falling = 0x10
}EXTITrigger_TypeDef;





 
typedef struct
{
  u32 EXTI_Line;
  EXTIMode_TypeDef EXTI_Mode;
  EXTITrigger_TypeDef EXTI_Trigger;
  FunctionalState EXTI_LineCmd;
}EXTI_InitTypeDef;

 
 
#line 80 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_exti.h"



#line 93 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_exti.h"
                                 
 
 
void EXTI_DeInit(void);
void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct);
void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct);
void EXTI_GenerateSWInterrupt(u32 EXTI_Line);
FlagStatus EXTI_GetFlagStatus(u32 EXTI_Line);
void EXTI_ClearFlag(u32 EXTI_Line);
ITStatus EXTI_GetITStatus(u32 EXTI_Line);
void EXTI_ClearITPendingBit(u32 EXTI_Line);



 
#line 54 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_flash.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_flash.h"

 

 
typedef enum
{ 
  FLASH_BUSY = 1,
  FLASH_ERROR_PG,
  FLASH_ERROR_WRP,
  FLASH_COMPLETE,
  FLASH_TIMEOUT
}FLASH_Status;


 








 







 







 

 
#line 97 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_flash.h"

 
#line 132 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_flash.h"






 





 





 





 





 





 






								 
 
 
 
void FLASH_SetLatency(u32 FLASH_Latency);
void FLASH_HalfCycleAccessCmd(u32 FLASH_HalfCycleAccess);
void FLASH_PrefetchBufferCmd(u32 FLASH_PrefetchBuffer);


void FLASH_Unlock(void);
void FLASH_Lock(void);
FLASH_Status FLASH_ErasePage(u32 Page_Address);
FLASH_Status FLASH_EraseAllPages(void);
FLASH_Status FLASH_EraseOptionBytes(void);
FLASH_Status FLASH_ProgramWord(u32 Address, u32 Data);
FLASH_Status FLASH_ProgramHalfWord(u32 Address, u16 Data);
FLASH_Status FLASH_ProgramOptionByteData(u32 Address, u8 Data);
FLASH_Status FLASH_EnableWriteProtection(u32 FLASH_Pages);
FLASH_Status FLASH_ReadOutProtection(FunctionalState NewState);
FLASH_Status FLASH_UserOptionByteConfig(u16 OB_IWDG, u16 OB_STOP, u16 OB_STDBY);
u32 FLASH_GetUserOptionByte(void);
u32 FLASH_GetWriteProtectionOptionByte(void);
FlagStatus FLASH_GetReadOutProtectionStatus(void);
FlagStatus FLASH_GetPrefetchBufferStatus(void);
void FLASH_ITConfig(u16 FLASH_IT, FunctionalState NewState);
FlagStatus FLASH_GetFlagStatus(u16 FLASH_FLAG);
void FLASH_ClearFlag(u16 FLASH_FLAG);
FLASH_Status FLASH_GetStatus(void);
FLASH_Status FLASH_WaitForLastOperation(u32 Timeout);




 
#line 58 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_fsmc.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_fsmc.h"

 
 
typedef struct
{
  u32 FSMC_AddressSetupTime;
  u32 FSMC_AddressHoldTime;
  u32 FSMC_DataSetupTime;
  u32 FSMC_BusTurnAroundDuration;
  u32 FSMC_CLKDivision;
  u32 FSMC_DataLatency;
  u32 FSMC_AccessMode;
}FSMC_NORSRAMTimingInitTypeDef;

 
typedef struct
{
  u32 FSMC_Bank;
  u32 FSMC_DataAddressMux;
  u32 FSMC_MemoryType;
  u32 FSMC_MemoryDataWidth;
  u32 FSMC_BurstAccessMode;
  u32 FSMC_WaitSignalPolarity;
  u32 FSMC_WrapMode;
  u32 FSMC_WaitSignalActive;
  u32 FSMC_WriteOperation;
  u32 FSMC_WaitSignal;
  u32 FSMC_ExtendedMode;
  u32 FSMC_AsyncWait;
  u32 FSMC_WriteBurst;
   
  FSMC_NORSRAMTimingInitTypeDef* FSMC_ReadWriteTimingStruct;
   
  FSMC_NORSRAMTimingInitTypeDef* FSMC_WriteTimingStruct;
}FSMC_NORSRAMInitTypeDef;

 
typedef struct
{
  u32 FSMC_SetupTime;
  u32 FSMC_WaitSetupTime;
  u32 FSMC_HoldSetupTime;
  u32 FSMC_HiZSetupTime;
}FSMC_NAND_PCCARDTimingInitTypeDef;

 
typedef struct
{
  u32 FSMC_Bank;
  u32 FSMC_Waitfeature;
  u32 FSMC_MemoryDataWidth;
  u32 FSMC_ECC;
  u32 FSMC_ECCPageSize;
  u32 FSMC_AddressLowMapping;
  u32 FSMC_TCLRSetupTime;
  u32 FSMC_TARSetupTime;
   
  FSMC_NAND_PCCARDTimingInitTypeDef*  FSMC_CommonSpaceTimingStruct;
   
  FSMC_NAND_PCCARDTimingInitTypeDef*  FSMC_AttributeSpaceTimingStruct;
}FSMC_NANDInitTypeDef;

 
typedef struct
{
  u32 FSMC_Waitfeature;
  u32 FSMC_AddressLowMapping;
  u32 FSMC_TCLRSetupTime;
  u32 FSMC_TARSetupTime;
   
  FSMC_NAND_PCCARDTimingInitTypeDef*  FSMC_CommonSpaceTimingStruct;
   
  FSMC_NAND_PCCARDTimingInitTypeDef*  FSMC_AttributeSpaceTimingStruct;
   
  FSMC_NAND_PCCARDTimingInitTypeDef*  FSMC_IOSpaceTimingStruct;
}FSMC_PCCARDInitTypeDef;

 
 
#line 109 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_fsmc.h"













                                    





 
 






 









                                     
 





                                      
                               
 






                                   





                                        
  





                                 
                                  





                                    
 





                              
 






 





                               
 





                                  
                                   






 


 


 


 


 


 


 









                                  
 
 





                                    
 





                                    
 





                                            
 
#line 276 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_fsmc.h"

#line 283 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_fsmc.h"
                                                              
 





 


 


 


 


 


 


 










 











 
 
void FSMC_NORSRAMDeInit(u32 FSMC_Bank);
void FSMC_NANDDeInit(u32 FSMC_Bank);
void FSMC_PCCARDDeInit(void);
void FSMC_NORSRAMInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct);
void FSMC_NANDInit(FSMC_NANDInitTypeDef* FSMC_NANDInitStruct);
void FSMC_PCCARDInit(FSMC_PCCARDInitTypeDef* FSMC_PCCARDInitStruct);
void FSMC_NORSRAMStructInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct);
void FSMC_NANDStructInit(FSMC_NANDInitTypeDef* FSMC_NANDInitStruct);
void FSMC_PCCARDStructInit(FSMC_PCCARDInitTypeDef* FSMC_PCCARDInitStruct);
void FSMC_NORSRAMCmd(u32 FSMC_Bank, FunctionalState NewState);
void FSMC_NANDCmd(u32 FSMC_Bank, FunctionalState NewState);
void FSMC_PCCARDCmd(FunctionalState NewState);
void FSMC_NANDECCCmd(u32 FSMC_Bank, FunctionalState NewState);
u32 FSMC_GetECC(u32 FSMC_Bank);
void FSMC_ITConfig(u32 FSMC_Bank, u32 FSMC_IT, FunctionalState NewState);
FlagStatus FSMC_GetFlagStatus(u32 FSMC_Bank, u32 FSMC_FLAG);
void FSMC_ClearFlag(u32 FSMC_Bank, u32 FSMC_FLAG);
ITStatus FSMC_GetITStatus(u32 FSMC_Bank, u32 FSMC_IT);
void FSMC_ClearITPendingBit(u32 FSMC_Bank, u32 FSMC_IT);



 
#line 62 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_gpio.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_gpio.h"

 
#line 32 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_gpio.h"
                                     
 
typedef enum
{ 
  GPIO_Speed_10MHz = 1,
  GPIO_Speed_2MHz, 
  GPIO_Speed_50MHz
}GPIOSpeed_TypeDef;



                                         
 
typedef enum
{ GPIO_Mode_AIN = 0x0,
  GPIO_Mode_IN_FLOATING = 0x04,
  GPIO_Mode_IPD = 0x28,
  GPIO_Mode_IPU = 0x48,
  GPIO_Mode_Out_OD = 0x14,
  GPIO_Mode_Out_PP = 0x10,
  GPIO_Mode_AF_OD = 0x1C,
  GPIO_Mode_AF_PP = 0x18
}GPIOMode_TypeDef;





                              
 
typedef struct
{
  u16 GPIO_Pin;
  GPIOSpeed_TypeDef GPIO_Speed;
  GPIOMode_TypeDef GPIO_Mode;
}GPIO_InitTypeDef;

 
typedef enum
{ Bit_RESET = 0,
  Bit_SET
}BitAction;


 
 
#line 95 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_gpio.h"



#line 114 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_gpio.h"
                            
 
#line 141 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_gpio.h"


#line 156 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_gpio.h"
                              
 
#line 165 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_gpio.h"






                                         
#line 179 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_gpio.h"
                                       
 
#line 197 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_gpio.h"

#line 214 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_gpio.h"
                          
 
 
void GPIO_DeInit(GPIO_TypeDef* GPIOx);
void GPIO_AFIODeInit(void);
void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct);
void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct);
u8 GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, u16 GPIO_Pin);
u16 GPIO_ReadInputData(GPIO_TypeDef* GPIOx);
u8 GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, u16 GPIO_Pin);
u16 GPIO_ReadOutputData(GPIO_TypeDef* GPIOx);
void GPIO_SetBits(GPIO_TypeDef* GPIOx, u16 GPIO_Pin);
void GPIO_ResetBits(GPIO_TypeDef* GPIOx, u16 GPIO_Pin);
void GPIO_WriteBit(GPIO_TypeDef* GPIOx, u16 GPIO_Pin, BitAction BitVal);
void GPIO_Write(GPIO_TypeDef* GPIOx, u16 PortVal);
void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, u16 GPIO_Pin);
void GPIO_EventOutputConfig(u8 GPIO_PortSource, u8 GPIO_PinSource);
void GPIO_EventOutputCmd(FunctionalState NewState);
void GPIO_PinRemapConfig(u32 GPIO_Remap, FunctionalState NewState);
void GPIO_EXTILineConfig(u8 GPIO_PortSource, u8 GPIO_PinSource);



 
#line 66 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_i2c.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_i2c.h"

 
 
typedef struct
{
  u16 I2C_Mode;
  u16 I2C_DutyCycle;
  u16 I2C_OwnAddress1;
  u16 I2C_Ack;
  u16 I2C_AcknowledgedAddress;
  u32 I2C_ClockSpeed;
}I2C_InitTypeDef;

 



 







 






 






 






 






 
#line 86 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_i2c.h"

#line 96 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_i2c.h"

 






 






 






 
#line 133 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_i2c.h"

#line 140 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_i2c.h"

#line 148 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_i2c.h"

 
#line 171 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_i2c.h"

#line 178 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_i2c.h"

#line 190 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_i2c.h"

 
 






 

     
 


 


 


 



 


 

      
 

                                          
 


#line 246 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_i2c.h"

 

 


 
 
void I2C_DeInit(I2C_TypeDef* I2Cx);
void I2C_Init(I2C_TypeDef* I2Cx, I2C_InitTypeDef* I2C_InitStruct);
void I2C_StructInit(I2C_InitTypeDef* I2C_InitStruct);
void I2C_Cmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
void I2C_DMACmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
void I2C_DMALastTransferCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
void I2C_GenerateSTART(I2C_TypeDef* I2Cx, FunctionalState NewState);
void I2C_GenerateSTOP(I2C_TypeDef* I2Cx, FunctionalState NewState);
void I2C_AcknowledgeConfig(I2C_TypeDef* I2Cx, FunctionalState NewState);
void I2C_OwnAddress2Config(I2C_TypeDef* I2Cx, u8 Address);
void I2C_DualAddressCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
void I2C_GeneralCallCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
void I2C_ITConfig(I2C_TypeDef* I2Cx, u16 I2C_IT, FunctionalState NewState);
void I2C_SendData(I2C_TypeDef* I2Cx, u8 Data);
u8 I2C_ReceiveData(I2C_TypeDef* I2Cx);
void I2C_Send7bitAddress(I2C_TypeDef* I2Cx, u8 Address, u8 I2C_Direction);
u16 I2C_ReadRegister(I2C_TypeDef* I2Cx, u8 I2C_Register);
void I2C_SoftwareResetCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
void I2C_SMBusAlertConfig(I2C_TypeDef* I2Cx, u16 I2C_SMBusAlert);
void I2C_TransmitPEC(I2C_TypeDef* I2Cx, FunctionalState NewState);
void I2C_PECPositionConfig(I2C_TypeDef* I2Cx, u16 I2C_PECPosition);
void I2C_CalculatePEC(I2C_TypeDef* I2Cx, FunctionalState NewState);
u8 I2C_GetPEC(I2C_TypeDef* I2Cx);
void I2C_ARPCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
void I2C_StretchClockCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
void I2C_FastModeDutyCycleConfig(I2C_TypeDef* I2Cx, u16 I2C_DutyCycle);
u32 I2C_GetLastEvent(I2C_TypeDef* I2Cx);
ErrorStatus I2C_CheckEvent(I2C_TypeDef* I2Cx, u32 I2C_EVENT);
FlagStatus I2C_GetFlagStatus(I2C_TypeDef* I2Cx, u32 I2C_FLAG);
void I2C_ClearFlag(I2C_TypeDef* I2Cx, u32 I2C_FLAG);
ITStatus I2C_GetITStatus(I2C_TypeDef* I2Cx, u32 I2C_IT);
void I2C_ClearITPendingBit(I2C_TypeDef* I2Cx, u32 I2C_IT);



 
#line 70 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_iwdg.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_iwdg.h"

 
 
 






 
#line 41 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_iwdg.h"

#line 49 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_iwdg.h"

 







 
 
void IWDG_WriteAccessCmd(u16 IWDG_WriteAccess);
void IWDG_SetPrescaler(u8 IWDG_Prescaler);
void IWDG_SetReload(u16 Reload);
void IWDG_ReloadCounter(void);
void IWDG_Enable(void);
FlagStatus IWDG_GetFlagStatus(u16 IWDG_FLAG);



 
#line 74 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_nvic.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_nvic.h"

 
 
typedef struct
{
  u8 NVIC_IRQChannel;
  u8 NVIC_IRQChannelPreemptionPriority;
  u8 NVIC_IRQChannelSubPriority;
  FunctionalState NVIC_IRQChannelCmd;
} NVIC_InitTypeDef;

 
 
#line 96 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_nvic.h"


#line 158 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_nvic.h"


 
#line 170 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_nvic.h"





#line 182 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_nvic.h"












#line 201 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_nvic.h"











 






 








 
#line 239 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_nvic.h"












 
 
void NVIC_DeInit(void);
void NVIC_SCBDeInit(void);
void NVIC_PriorityGroupConfig(u32 NVIC_PriorityGroup);
void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct);
void NVIC_StructInit(NVIC_InitTypeDef* NVIC_InitStruct);
void NVIC_SETPRIMASK(void);
void NVIC_RESETPRIMASK(void);
void NVIC_SETFAULTMASK(void);
void NVIC_RESETFAULTMASK(void);
void NVIC_BASEPRICONFIG(u32 NewPriority);
u32 NVIC_GetBASEPRI(void);
u16 NVIC_GetCurrentPendingIRQChannel(void);
ITStatus NVIC_GetIRQChannelPendingBitStatus(u8 NVIC_IRQChannel);
void NVIC_SetIRQChannelPendingBit(u8 NVIC_IRQChannel);
void NVIC_ClearIRQChannelPendingBit(u8 NVIC_IRQChannel);
u16 NVIC_GetCurrentActiveHandler(void);
ITStatus NVIC_GetIRQChannelActiveBitStatus(u8 NVIC_IRQChannel);
u32 NVIC_GetCPUID(void);
void NVIC_SetVectorTable(u32 NVIC_VectTab, u32 Offset);
void NVIC_GenerateSystemReset(void);
void NVIC_GenerateCoreReset(void);
void NVIC_SystemLPConfig(u8 LowPowerMode, FunctionalState NewState);
void NVIC_SystemHandlerConfig(u32 SystemHandler, FunctionalState NewState);
void NVIC_SystemHandlerPriorityConfig(u32 SystemHandler, u8 SystemHandlerPreemptionPriority,
                                      u8 SystemHandlerSubPriority);
ITStatus NVIC_GetSystemHandlerPendingBitStatus(u32 SystemHandler);
void NVIC_SetSystemHandlerPendingBit(u32 SystemHandler);
void NVIC_ClearSystemHandlerPendingBit(u32 SystemHandler);
ITStatus NVIC_GetSystemHandlerActiveBitStatus(u32 SystemHandler);
u32 NVIC_GetFaultHandlerSources(u32 SystemHandler);
u32 NVIC_GetFaultAddress(u32 SystemHandler);



 
#line 78 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_pwr.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_pwr.h"

 
 
 
#line 35 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_pwr.h"






 






 




 
 








 
 
void PWR_DeInit(void);
void PWR_BackupAccessCmd(FunctionalState NewState);
void PWR_PVDCmd(FunctionalState NewState);
void PWR_PVDLevelConfig(u32 PWR_PVDLevel);
void PWR_WakeUpPinCmd(FunctionalState NewState);
void PWR_EnterSTOPMode(u32 PWR_Regulator, u8 PWR_STOPEntry);
void PWR_EnterSTANDBYMode(void);
FlagStatus PWR_GetFlagStatus(u32 PWR_FLAG);
void PWR_ClearFlag(u32 PWR_FLAG);



 
#line 82 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_rcc.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_rcc.h"

 
typedef struct
{
  u32 SYSCLK_Frequency;
  u32 HCLK_Frequency;
  u32 PCLK1_Frequency;
  u32 PCLK2_Frequency;
  u32 ADCCLK_Frequency;
}RCC_ClocksTypeDef;

 
 







 








 
#line 68 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_rcc.h"

#line 77 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_rcc.h"

 








 
#line 97 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_rcc.h"







 










 
#line 122 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_rcc.h"







 






 








 







 








 
#line 170 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_rcc.h"



 
#line 190 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_rcc.h"



 
#line 215 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_rcc.h"



 










 
#line 241 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_rcc.h"

#line 248 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_rcc.h"



 
 
void RCC_DeInit(void);
void RCC_HSEConfig(u32 RCC_HSE);
ErrorStatus RCC_WaitForHSEStartUp(void);
void RCC_AdjustHSICalibrationValue(u8 HSICalibrationValue);
void RCC_HSICmd(FunctionalState NewState);
void RCC_PLLConfig(u32 RCC_PLLSource, u32 RCC_PLLMul);
void RCC_PLLCmd(FunctionalState NewState);
void RCC_SYSCLKConfig(u32 RCC_SYSCLKSource);
u8 RCC_GetSYSCLKSource(void);
void RCC_HCLKConfig(u32 RCC_SYSCLK);
void RCC_PCLK1Config(u32 RCC_HCLK);
void RCC_PCLK2Config(u32 RCC_HCLK);
void RCC_ITConfig(u8 RCC_IT, FunctionalState NewState);
void RCC_USBCLKConfig(u32 RCC_USBCLKSource);
void RCC_ADCCLKConfig(u32 RCC_PCLK2);
void RCC_LSEConfig(u8 RCC_LSE);
void RCC_LSICmd(FunctionalState NewState);
void RCC_RTCCLKConfig(u32 RCC_RTCCLKSource);
void RCC_RTCCLKCmd(FunctionalState NewState);
void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks);
void RCC_AHBPeriphClockCmd(u32 RCC_AHBPeriph, FunctionalState NewState);
void RCC_APB2PeriphClockCmd(u32 RCC_APB2Periph, FunctionalState NewState);
void RCC_APB1PeriphClockCmd(u32 RCC_APB1Periph, FunctionalState NewState);
void RCC_APB2PeriphResetCmd(u32 RCC_APB2Periph, FunctionalState NewState);
void RCC_APB1PeriphResetCmd(u32 RCC_APB1Periph, FunctionalState NewState);
void RCC_BackupResetCmd(FunctionalState NewState);
void RCC_ClockSecuritySystemCmd(FunctionalState NewState);
void RCC_MCOConfig(u8 RCC_MCO);
FlagStatus RCC_GetFlagStatus(u8 RCC_FLAG);
void RCC_ClearFlag(void);
ITStatus RCC_GetITStatus(u8 RCC_IT);
void RCC_ClearITPendingBit(u8 RCC_IT);



 
#line 86 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_rtc.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_rtc.h"

 
 
 








                                                                     
 













                           
 
 
void RTC_ITConfig(u16 RTC_IT, FunctionalState NewState);
void RTC_EnterConfigMode(void);
void RTC_ExitConfigMode(void);
u32  RTC_GetCounter(void);
void RTC_SetCounter(u32 CounterValue);
void RTC_SetPrescaler(u32 PrescalerValue);
void RTC_SetAlarm(u32 AlarmValue);
u32  RTC_GetDivider(void);
void RTC_WaitForLastTask(void);
void RTC_WaitForSynchro(void);
FlagStatus RTC_GetFlagStatus(u16 RTC_FLAG);
void RTC_ClearFlag(u16 RTC_FLAG);
ITStatus RTC_GetITStatus(u16 RTC_IT);
void RTC_ClearITPendingBit(u16 RTC_IT);



 
#line 90 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_sdio.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_sdio.h"

 
typedef struct
{
  u8 SDIO_ClockDiv;
  u32 SDIO_ClockEdge;
  u32 SDIO_ClockBypass;
  u32 SDIO_ClockPowerSave;
  u32 SDIO_BusWide;
  u32 SDIO_HardwareFlowControl;
} SDIO_InitTypeDef;

typedef struct
{
  u32 SDIO_Argument;
  u32 SDIO_CmdIndex;
  u32 SDIO_Response;
  u32 SDIO_Wait;
  u32 SDIO_CPSM;
} SDIO_CmdInitTypeDef;

typedef struct
{
  u32 SDIO_DataTimeOut;
  u32 SDIO_DataLength;
  u32 SDIO_DataBlockSize;
  u32 SDIO_TransferDir;
  u32 SDIO_TransferMode;
  u32 SDIO_DPSM;
} SDIO_DataInitTypeDef;

 
 





                                   






  






 






                                
  





                                  
 





 
#line 121 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_sdio.h"



 


 








 







 





 








 


 
#line 178 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_sdio.h"

#line 194 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_sdio.h"

 






 






 





 
#line 240 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_sdio.h"

#line 265 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_sdio.h"



#line 292 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_sdio.h"


                                                        
 






 
 
void SDIO_DeInit(void);
void SDIO_Init(SDIO_InitTypeDef* SDIO_InitStruct);
void SDIO_StructInit(SDIO_InitTypeDef* SDIO_InitStruct);
void SDIO_ClockCmd(FunctionalState NewState);
void SDIO_SetPowerState(u32 SDIO_PowerState);
u32 SDIO_GetPowerState(void);
void SDIO_ITConfig(u32 SDIO_IT, FunctionalState NewState);
void SDIO_DMACmd(FunctionalState NewState);
void SDIO_SendCommand(SDIO_CmdInitTypeDef *SDIO_CmdInitStruct);
void SDIO_CmdStructInit(SDIO_CmdInitTypeDef* SDIO_CmdInitStruct);
u8 SDIO_GetCommandResponse(void);
u32 SDIO_GetResponse(u32 SDIO_RESP);
void SDIO_DataConfig(SDIO_DataInitTypeDef* SDIO_DataInitStruct);
void SDIO_DataStructInit(SDIO_DataInitTypeDef* SDIO_DataInitStruct);
u32 SDIO_GetDataCounter(void);
u32 SDIO_ReadData(void);
void SDIO_WriteData(u32 Data);
u32 SDIO_GetFIFOCount(void);
void SDIO_StartSDIOReadWait(FunctionalState NewState);
void SDIO_StopSDIOReadWait(FunctionalState NewState);
void SDIO_SetSDIOReadWaitMode(u32 SDIO_ReadWaitMode);
void SDIO_SetSDIOOperation(FunctionalState NewState);
void SDIO_SendSDIOSuspendCmd(FunctionalState NewState);
void SDIO_CommandCompletionCmd(FunctionalState NewState);
void SDIO_CEATAITCmd(FunctionalState NewState);
void SDIO_SendCEATACmd(FunctionalState NewState);
FlagStatus SDIO_GetFlagStatus(u32 SDIO_FLAG);
void SDIO_ClearFlag(u32 SDIO_FLAG);
ITStatus SDIO_GetITStatus(u32 SDIO_IT);
void SDIO_ClearITPendingBit(u32 SDIO_IT);



 
#line 94 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_spi.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_spi.h"

 
 
typedef struct
{
  u16 SPI_Direction;
  u16 SPI_Mode;
  u16 SPI_DataSize;
  u16 SPI_CPOL;
  u16 SPI_CPHA;
  u16 SPI_NSS;
  u16 SPI_BaudRatePrescaler;
  u16 SPI_FirstBit;
  u16 SPI_CRCPolynomial;
}SPI_InitTypeDef;

 
typedef struct
{
  u16 I2S_Mode;
  u16 I2S_Standard;
  u16 I2S_DataFormat;
  u16 I2S_MCLKOutput;
  u16 I2S_AudioFreq;
  u16 I2S_CPOL;
}I2S_InitTypeDef;

 








 










 






 






 






 






 






 
#line 114 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_spi.h"

#line 123 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_spi.h"

 






 










 












 










  






 
#line 180 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_spi.h"

#line 187 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_spi.h"

 






 





 






 





 






 






















 
#line 253 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_spi.h"

#line 260 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_spi.h"

 


 
 
void SPI_I2S_DeInit(SPI_TypeDef* SPIx);
void SPI_Init(SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct);
void I2S_Init(SPI_TypeDef* SPIx, I2S_InitTypeDef* I2S_InitStruct);
void SPI_StructInit(SPI_InitTypeDef* SPI_InitStruct);
void I2S_StructInit(I2S_InitTypeDef* I2S_InitStruct);
void SPI_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState);
void I2S_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState);
void SPI_I2S_ITConfig(SPI_TypeDef* SPIx, u8 SPI_I2S_IT, FunctionalState NewState);
void SPI_I2S_DMACmd(SPI_TypeDef* SPIx, u16 SPI_I2S_DMAReq, FunctionalState NewState);
void SPI_I2S_SendData(SPI_TypeDef* SPIx, u16 Data);
u16 SPI_I2S_ReceiveData(SPI_TypeDef* SPIx);
void SPI_NSSInternalSoftwareConfig(SPI_TypeDef* SPIx, u16 SPI_NSSInternalSoft);
void SPI_SSOutputCmd(SPI_TypeDef* SPIx, FunctionalState NewState);
void SPI_DataSizeConfig(SPI_TypeDef* SPIx, u16 SPI_DataSize);
void SPI_TransmitCRC(SPI_TypeDef* SPIx);
void SPI_CalculateCRC(SPI_TypeDef* SPIx, FunctionalState NewState);
u16 SPI_GetCRC(SPI_TypeDef* SPIx, u8 SPI_CRC);
u16 SPI_GetCRCPolynomial(SPI_TypeDef* SPIx);
void SPI_BiDirectionalLineConfig(SPI_TypeDef* SPIx, u16 SPI_Direction);
FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, u16 SPI_I2S_FLAG);
void SPI_I2S_ClearFlag(SPI_TypeDef* SPIx, u16 SPI_I2S_FLAG);
ITStatus SPI_I2S_GetITStatus(SPI_TypeDef* SPIx, u8 SPI_I2S_IT);
void SPI_I2S_ClearITPendingBit(SPI_TypeDef* SPIx, u8 SPI_I2S_IT);



 
#line 98 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_systick.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_systick.h"

 
 
 






 








 










 
 
void SysTick_CLKSourceConfig(u32 SysTick_CLKSource);
void SysTick_SetReload(u32 Reload);
void SysTick_CounterCmd(u32 SysTick_Counter);
void SysTick_ITConfig(FunctionalState NewState);
u32 SysTick_GetCounter(void);
FlagStatus SysTick_GetFlagStatus(u8 SysTick_FLAG);



 
#line 102 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"

 

 
typedef struct
{
  u16 TIM_Prescaler;
  u16 TIM_CounterMode;
  u16 TIM_Period;
  u16 TIM_ClockDivision;
  u8 TIM_RepetitionCounter;
} TIM_TimeBaseInitTypeDef;

 
typedef struct
{
  u16 TIM_OCMode;
  u16 TIM_OutputState;
  u16 TIM_OutputNState;
  u16 TIM_Pulse;
  u16 TIM_OCPolarity;
  u16 TIM_OCNPolarity;
  u16 TIM_OCIdleState;
  u16 TIM_OCNIdleState;
} TIM_OCInitTypeDef;

 
typedef struct
{
  u16 TIM_Channel;
  u16 TIM_ICPolarity;
  u16 TIM_ICSelection;
  u16 TIM_ICPrescaler;
  u16 TIM_ICFilter;
} TIM_ICInitTypeDef;

 
typedef struct
{
  u16 TIM_OSSRState;
  u16 TIM_OSSIState;
  u16 TIM_LOCKLevel; 
  u16 TIM_DeadTime;
  u16 TIM_Break;
  u16 TIM_BreakPolarity;
  u16 TIM_AutomaticOutput;
} TIM_BDTRInitTypeDef;

                              

#line 81 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"




#line 91 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"

 
#line 99 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"

#line 106 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"

#line 115 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"
 






 
















 








 












 






 






 






 






 






 






 






 






 





 










 






 






 






 






 






 








 










 
#line 298 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"



#line 308 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"

#line 317 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"

 
#line 338 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"

#line 358 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"

 
#line 378 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"

#line 397 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"

 
#line 406 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"



#line 416 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"

 










 
#line 437 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"

#line 446 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"






 








 






 






 






  








 
#line 500 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"



#line 510 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"

 






 






 





                                     
 






  
#line 548 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"

#line 557 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"

#line 593 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"

 










 






 
#line 625 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"

#line 638 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"

#line 646 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"

#line 665 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_tim.h"
                                                                                            
 


 


 
 

void TIM_DeInit(TIM_TypeDef* TIMx);
void TIM_TimeBaseInit(TIM_TypeDef* TIMx, TIM_TimeBaseInitTypeDef* TIM_TimeBaseInitStruct);
void TIM_OC1Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct);
void TIM_OC2Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct);
void TIM_OC3Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct);
void TIM_OC4Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct);
void TIM_ICInit(TIM_TypeDef* TIMx, TIM_ICInitTypeDef* TIM_ICInitStruct);
void TIM_PWMIConfig(TIM_TypeDef* TIMx, TIM_ICInitTypeDef* TIM_ICInitStruct);
void TIM_BDTRConfig(TIM_TypeDef* TIMx, TIM_BDTRInitTypeDef *TIM_BDTRInitStruct);
void TIM_TimeBaseStructInit(TIM_TimeBaseInitTypeDef* TIM_TimeBaseInitStruct);
void TIM_OCStructInit(TIM_OCInitTypeDef* TIM_OCInitStruct);
void TIM_ICStructInit(TIM_ICInitTypeDef* TIM_ICInitStruct);
void TIM_BDTRStructInit(TIM_BDTRInitTypeDef* TIM_BDTRInitStruct);
void TIM_Cmd(TIM_TypeDef* TIMx, FunctionalState NewState);
void TIM_CtrlPWMOutputs(TIM_TypeDef* TIMx, FunctionalState NewState);
void TIM_ITConfig(TIM_TypeDef* TIMx, u16 TIM_IT, FunctionalState NewState);
void TIM_GenerateEvent(TIM_TypeDef* TIMx, u16 TIM_EventSource);
void TIM_DMAConfig(TIM_TypeDef* TIMx, u16 TIM_DMABase, u16 TIM_DMABurstLength);
void TIM_DMACmd(TIM_TypeDef* TIMx, u16 TIM_DMASource, FunctionalState NewState);
void TIM_InternalClockConfig(TIM_TypeDef* TIMx);
void TIM_ITRxExternalClockConfig(TIM_TypeDef* TIMx, u16 TIM_InputTriggerSource);
void TIM_TIxExternalClockConfig(TIM_TypeDef* TIMx, u16 TIM_TIxExternalCLKSource,
                                u16 TIM_ICPolarity, u16 ICFilter);                                
void TIM_ETRClockMode1Config(TIM_TypeDef* TIMx, u16 TIM_ExtTRGPrescaler, u16 TIM_ExtTRGPolarity,
                             u16 ExtTRGFilter);
void TIM_ETRClockMode2Config(TIM_TypeDef* TIMx, u16 TIM_ExtTRGPrescaler, 
                             u16 TIM_ExtTRGPolarity, u16 ExtTRGFilter);
void TIM_ETRConfig(TIM_TypeDef* TIMx, u16 TIM_ExtTRGPrescaler, u16 TIM_ExtTRGPolarity,
                   u16 ExtTRGFilter);
void TIM_PrescalerConfig(TIM_TypeDef* TIMx, u16 Prescaler, u16 TIM_PSCReloadMode);
void TIM_CounterModeConfig(TIM_TypeDef* TIMx, u16 TIM_CounterMode);
void TIM_SelectInputTrigger(TIM_TypeDef* TIMx, u16 TIM_InputTriggerSource);
void TIM_EncoderInterfaceConfig(TIM_TypeDef* TIMx, u16 TIM_EncoderMode,
                                u16 TIM_IC1Polarity, u16 TIM_IC2Polarity);
void TIM_ForcedOC1Config(TIM_TypeDef* TIMx, u16 TIM_ForcedAction);
void TIM_ForcedOC2Config(TIM_TypeDef* TIMx, u16 TIM_ForcedAction);
void TIM_ForcedOC3Config(TIM_TypeDef* TIMx, u16 TIM_ForcedAction);
void TIM_ForcedOC4Config(TIM_TypeDef* TIMx, u16 TIM_ForcedAction);
void TIM_ARRPreloadConfig(TIM_TypeDef* TIMx, FunctionalState NewState);
void TIM_SelectCOM(TIM_TypeDef* TIMx, FunctionalState NewState);
void TIM_SelectCCDMA(TIM_TypeDef* TIMx, FunctionalState NewState);
void TIM_CCPreloadControl(TIM_TypeDef* TIMx, FunctionalState NewState);
void TIM_OC1PreloadConfig(TIM_TypeDef* TIMx, u16 TIM_OCPreload);
void TIM_OC2PreloadConfig(TIM_TypeDef* TIMx, u16 TIM_OCPreload);
void TIM_OC3PreloadConfig(TIM_TypeDef* TIMx, u16 TIM_OCPreload);
void TIM_OC4PreloadConfig(TIM_TypeDef* TIMx, u16 TIM_OCPreload);
void TIM_OC1FastConfig(TIM_TypeDef* TIMx, u16 TIM_OCFast);
void TIM_OC2FastConfig(TIM_TypeDef* TIMx, u16 TIM_OCFast);
void TIM_OC3FastConfig(TIM_TypeDef* TIMx, u16 TIM_OCFast);
void TIM_OC4FastConfig(TIM_TypeDef* TIMx, u16 TIM_OCFast);
void TIM_ClearOC1Ref(TIM_TypeDef* TIMx, u16 TIM_OCClear);
void TIM_ClearOC2Ref(TIM_TypeDef* TIMx, u16 TIM_OCClear);
void TIM_ClearOC3Ref(TIM_TypeDef* TIMx, u16 TIM_OCClear);
void TIM_ClearOC4Ref(TIM_TypeDef* TIMx, u16 TIM_OCClear);
void TIM_OC1PolarityConfig(TIM_TypeDef* TIMx, u16 TIM_OCPolarity);
void TIM_OC1NPolarityConfig(TIM_TypeDef* TIMx, u16 TIM_OCNPolarity);
void TIM_OC2PolarityConfig(TIM_TypeDef* TIMx, u16 TIM_OCPolarity);
void TIM_OC2NPolarityConfig(TIM_TypeDef* TIMx, u16 TIM_OCNPolarity);
void TIM_OC3PolarityConfig(TIM_TypeDef* TIMx, u16 TIM_OCPolarity);
void TIM_OC3NPolarityConfig(TIM_TypeDef* TIMx, u16 TIM_OCNPolarity);
void TIM_OC4PolarityConfig(TIM_TypeDef* TIMx, u16 TIM_OCPolarity);
void TIM_CCxCmd(TIM_TypeDef* TIMx, u16 TIM_Channel, u16 TIM_CCx);
void TIM_CCxNCmd(TIM_TypeDef* TIMx, u16 TIM_Channel, u16 TIM_CCxN);
void TIM_SelectOCxM(TIM_TypeDef* TIMx, u16 TIM_Channel, u16 TIM_OCMode);
void TIM_UpdateDisableConfig(TIM_TypeDef* TIMx, FunctionalState NewState);
void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, u16 TIM_UpdateSource);
void TIM_SelectHallSensor(TIM_TypeDef* TIMx, FunctionalState NewState);
void TIM_SelectOnePulseMode(TIM_TypeDef* TIMx, u16 TIM_OPMode);
void TIM_SelectOutputTrigger(TIM_TypeDef* TIMx, u16 TIM_TRGOSource);
void TIM_SelectSlaveMode(TIM_TypeDef* TIMx, u16 TIM_SlaveMode);
void TIM_SelectMasterSlaveMode(TIM_TypeDef* TIMx, u16 TIM_MasterSlaveMode);
void TIM_SetCounter(TIM_TypeDef* TIMx, u16 Counter);
void TIM_SetAutoreload(TIM_TypeDef* TIMx, u16 Autoreload);
void TIM_SetCompare1(TIM_TypeDef* TIMx, u16 Compare1);
void TIM_SetCompare2(TIM_TypeDef* TIMx, u16 Compare2);
void TIM_SetCompare3(TIM_TypeDef* TIMx, u16 Compare3);
void TIM_SetCompare4(TIM_TypeDef* TIMx, u16 Compare4);
void TIM_SetIC1Prescaler(TIM_TypeDef* TIMx, u16 TIM_ICPSC);
void TIM_SetIC2Prescaler(TIM_TypeDef* TIMx, u16 TIM_ICPSC);
void TIM_SetIC3Prescaler(TIM_TypeDef* TIMx, u16 TIM_ICPSC);
void TIM_SetIC4Prescaler(TIM_TypeDef* TIMx, u16 TIM_ICPSC);
void TIM_SetClockDivision(TIM_TypeDef* TIMx, u16 TIM_CKD);
u16 TIM_GetCapture1(TIM_TypeDef* TIMx);
u16 TIM_GetCapture2(TIM_TypeDef* TIMx);
u16 TIM_GetCapture3(TIM_TypeDef* TIMx);
u16 TIM_GetCapture4(TIM_TypeDef* TIMx);
u16 TIM_GetCounter(TIM_TypeDef* TIMx);
u16 TIM_GetPrescaler(TIM_TypeDef* TIMx);
FlagStatus TIM_GetFlagStatus(TIM_TypeDef* TIMx, u16 TIM_FLAG);
void TIM_ClearFlag(TIM_TypeDef* TIMx, u16 TIM_FLAG);
ITStatus TIM_GetITStatus(TIM_TypeDef* TIMx, u16 TIM_IT);
void TIM_ClearITPendingBit(TIM_TypeDef* TIMx, u16 TIM_IT);
                                                                                                             


 








#line 106 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_usart.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_usart.h"

 
 
typedef struct
{
  u32 USART_BaudRate;
  u16 USART_WordLength;
  u16 USART_StopBits;
  u16 USART_Parity;
  u16 USART_Mode;
  u16 USART_HardwareFlowControl;  
} USART_InitTypeDef;

 
typedef struct
{
  u16 USART_Clock;
  u16 USART_CPOL;
  u16 USART_CPHA;
  u16 USART_LastBit;
} USART_ClockInitTypeDef;

 















 


                                    



 









 








 





 















 






 




                               
 




 






 
#line 146 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_usart.h"






















 





 






 







 






 
#line 207 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_usart.h"






                              










 
 
void USART_DeInit(USART_TypeDef* USARTx);
void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct);
void USART_StructInit(USART_InitTypeDef* USART_InitStruct);
void USART_ClockInit(USART_TypeDef* USARTx, USART_ClockInitTypeDef* USART_ClockInitStruct);
void USART_ClockStructInit(USART_ClockInitTypeDef* USART_ClockInitStruct);
void USART_Cmd(USART_TypeDef* USARTx, FunctionalState NewState);
void USART_ITConfig(USART_TypeDef* USARTx, u16 USART_IT, FunctionalState NewState);
void USART_DMACmd(USART_TypeDef* USARTx, u16 USART_DMAReq, FunctionalState NewState);
void USART_SetAddress(USART_TypeDef* USARTx, u8 USART_Address);
void USART_WakeUpConfig(USART_TypeDef* USARTx, u16 USART_WakeUp);
void USART_ReceiverWakeUpCmd(USART_TypeDef* USARTx, FunctionalState NewState);
void USART_LINBreakDetectLengthConfig(USART_TypeDef* USARTx, u16 USART_LINBreakDetectLength);
void USART_LINCmd(USART_TypeDef* USARTx, FunctionalState NewState);
void USART_SendData(USART_TypeDef* USARTx, u16 Data);
u16 USART_ReceiveData(USART_TypeDef* USARTx);
void USART_SendBreak(USART_TypeDef* USARTx);
void USART_SetGuardTime(USART_TypeDef* USARTx, u8 USART_GuardTime);
void USART_SetPrescaler(USART_TypeDef* USARTx, u8 USART_Prescaler);
void USART_SmartCardCmd(USART_TypeDef* USARTx, FunctionalState NewState);
void USART_SmartCardNACKCmd(USART_TypeDef* USARTx, FunctionalState NewState);
void USART_HalfDuplexCmd(USART_TypeDef* USARTx, FunctionalState NewState);
void USART_IrDAConfig(USART_TypeDef* USARTx, u16 USART_IrDAMode);
void USART_IrDACmd(USART_TypeDef* USARTx, FunctionalState NewState);
FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, u16 USART_FLAG);
void USART_ClearFlag(USART_TypeDef* USARTx, u16 USART_FLAG);
ITStatus USART_GetITStatus(USART_TypeDef* USARTx, u16 USART_IT);
void USART_ClearITPendingBit(USART_TypeDef* USARTx, u16 USART_IT);



 
#line 110 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


#line 1 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_wwdg.h"














 

 



 
#line 23 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_wwdg.h"

 
 
 














 
 
void WWDG_DeInit(void);
void WWDG_SetPrescaler(u32 WWDG_Prescaler);
void WWDG_SetWindowValue(u8 WindowValue);
void WWDG_EnableIT(void);
void WWDG_SetCounter(u8 Counter);
void WWDG_Enable(u8 Counter);
FlagStatus WWDG_GetFlagStatus(void);
void WWDG_ClearFlag(void);



 
#line 114 "..\\user\\..\\gtlib\\gtDev\\STM32F10x\\stm32f10x_lib.h"


 
 
 
 
void debug(void);



 
#line 125 "..\\app\\APP\\gtlib.h"
#line 1 "..\\user\\..\\gtlib\\gtDev\\gtDev.h"



#line 5 "..\\user\\..\\gtlib\\gtDev\\gtDev.h"


 
typedef signed char     			S8;
typedef unsigned char   			U8;
typedef short           			S16;
typedef unsigned short  			U16;
typedef int             			S32;
typedef unsigned int    			U32;
typedef long long       			S64;
typedef unsigned long long 			U64;
typedef volatile signed char     	VS8;
typedef volatile unsigned char   	VU8;
typedef volatile short           	VS16;
typedef volatile unsigned short  	VU16;
typedef volatile int             	VS32;
typedef volatile unsigned int    	VU32;
typedef volatile long long       	VS64;
typedef volatile unsigned long long VU64;

typedef unsigned char   			BIT;
typedef unsigned int    			BOOL;

typedef float         				 fp32;                     
typedef double        				 fp64;                     




 											 						
extern int gt_gpio_cfg(U8 xPort,U8 xPin,U8 xMode,U8 sta,U8 xSpeed);					
extern int gt_gpio_set(U8 xPort,U8 xPin,U8 sta);								
extern int gt_gpio_get(U8 xPort,U8 xPin);									
		
extern void gt_us_delay(VU32 T);						
extern void gt_ms_delay(VU32 T);						

extern void gt_def_dint(void);						
extern void gt_def_enit(void);						

extern void gt_dev_init(void);
extern void gt_nvic_reset(void);		




 
extern void gt_io_init(void);				
extern void gt_io_set(U8 nID,U8 sta);	 					
extern U8 gt_io_get(U8 nID);	 						 
extern void gt_digital_play(U8 ucPort,U8 ucPin,U8 ucNum,U8 ucPoint);  

														   


 	
extern void gt_key_init(void);			
extern U32 gt_key_get(void);				



 
extern int gt_vk321x_init(void);			
extern void gt_vk321x_handler(void);
extern void gt_uart_handler(U8 xUart);
extern int gt_getchar(void);					
extern int gt_sendchar(int ch); 		

extern int gt_uart_open(U8 xUart,U32 xBaud,U8 xData,U8 xPari,U8 xStop,U16 rxbufsize,U16 txbufsize);
extern int gt_uart_close(U8 xUart);
extern int gt_uart_send(U8 xUart, const void *pData, int nLen);
extern int gt_uart_rev(U8 xUart, void* pBuf,int size,int nTmo,int ntry);




 
extern int gt_nand_init(void);
extern int gt_nand_readpage(U32 *pPage, void *pBuf, U32 *pDataEcc);
extern int gt_nand_progdata(U32 *pPage, const void *pBuf, U32 *pDataEcc);
extern int gt_nand_proghalfdouble(U32 *pPage, const void *pBuf0, const void *pBuf1, U32 *pDataEcc);
extern int gt_nand_progspare(U32 *pPage, const void *pBuf);
extern int gt_nand_eraseblock(U32 *pPage);




 
extern int gt_norf_init(void);											
extern int gt_norf_erase(U32 adr);									
extern int gt_norf_erasechip(void);								
extern int gt_norf_program(U32 adr, const U32 *pBuf, U32 nLen);	
extern int gt_norf_read(U32 adr, void *pBuf, U32 nLen);				




 




typedef struct
{
	U16 ucLcd_Xmax;
	U16 ucLcd_Ymax;
}gt_lcd_info[1];

extern void gt_lcd_init(void);
extern void gt_lcd_bgl(int nOnOff);						
extern void gt_lcd_drawpoint(int x, int y, U8 color);	
extern void gt_lcd_clearall(U8 color);					
extern void gt_lcd_redraw(void);						
extern void gt_lcd_setBR(char nBr);					
extern void gt_lcd_setPM(U8 nPm);					
extern void gt_lcd_getinfo(gt_lcd_info lcd_info);		




 
extern int gt_i2c_init(U8 p);
extern int gt_i2c_write(U8 nID, U32 nDev, U8 *pData, U32 nLen); 		
extern int gt_i2c_read(U8 nID, U32 nDev, U8 *pData, U32 nLen);				
extern int gt_i2c_writebyte(U8 nID, U32 nDev, U32 nAdr, U32 nData);
extern int gt_eeprom_read(U8 ucID,U8 ucDev_Adr,U32 unAdr,U8 *pData,U8 ucLen);
extern int gt_eeprom_write(U8 ucID,U8 ucDev_Adr,U32 unAdr,U8 *pData,U8 ucLen);




 
extern U8 gt_time_init(void);
extern U8 gt_get_time(time_t *pTime);
extern U8 gt_set_time(time_t tTime);
extern void gt_set_time_callback(time_t old,time_t now);

extern int gt_tim_config(U8 XTIM,U16 XTIM_PRESCALER,U16 XTIM_PERIOD);   



 














 
extern void gt_adc_init(U8 tmi, U16 xtmi_prescaler,U16 xtmi_period,U16 xtmi_pulse);			
extern void gt_adcithandler(void);					
extern void gt_adcithandler_half1(void);			
extern void gt_adcithandler_half2(void);
extern int gt_adc_get(U8 ch,U16 *p,U16 size,int nTmo);		
extern void gt_adc_open(void);				
extern void gt_adc_close(void);
extern void gt_tmi2_change(U16 xtmi_prescaler,U16 xtmi_period,U16 xtmi_pulse);

extern int gt_init_adc_nul(U8 ucID,U8 ucPort,U8 ucPin,U8 ucChannel,U8 ucCycle);
extern U32 gt_get_adc_nul(U8 ucID);



 
extern int gt_spi_init(U8 uID);
extern int gt_spi_config(U8 uID,U32 speed,U8 sckmode,U8 latchmode,U8 ucMode);
extern U8 gt_spi_transmit(U8 uID, U8 nData); 
extern U8 gt_spi_send(U8 uID, const void *psendbuf,int nLen);
extern void gt_spi_it_open(U8 uID);




extern U8 gt_spibus_config(U8 uID,U32 speed,U8 sckmode,U8 latchmode);
extern U8 gt_spibus_send(U8 uID, U8 *nData,U8 ucLen);



extern int gt_pvd_open(U32 level);
extern int gt_pvd_check(void);


extern int gt_ex_irq_config(U8 xPort,U8 xPin, U32 nTriggerMode, void (*handler)(void));




 
extern int gt_att7022_init(void);
extern int gt_att7022_Reset(void);
extern int gt_att7022_writereg(U8 uID, U32 nReg, U32 nData);
extern U32 gt_att7022_readreg(U8 uID, U32 nReg);




 
extern void gt_iwdg_open(void); 		
extern void gt_iwdg_reload(void);		




 	
extern int gt_dm9000_init(void);		
extern U32 gt_dm9000_regread(U32 reg);
extern void gt_dm9000_regwrite(U32 reg, U32 value);
extern int gt_dm9000_reset(void);
extern void gt_dm9000_writecmd(U32 cmd);
extern void gt_dm9000_writedat(U32 dat);
extern U32 gt_dm9000_readdat(void);
extern U32 gt_dm9000_readcmd(void);

extern int gt_eth_init(void);
extern int gt_eth_set(int flag);
extern int gt_eth_send(const unsigned char* buf,int size);
extern void ETH_IRQHandler (void); 


extern void gt_modem_init(void);		
extern void gt_modem_pwer(U8 x);
extern void gt_modem_act(U8 x);
extern void gt_modem_dtr(U8 x);
extern int gt_modem_dcd(void);

extern int gt_modem_step(unsigned int* nDelay);
extern int gt_modem_online(void);
extern int gt_ppp_open(unsigned char** buf,unsigned int* size);
extern int gt_ppp_send(const void* pBuf,int size);
extern int gt_ppp_recv(void* pBuf,int size);




 
extern int mutex_init(void);
extern void mutex_close(int mutex);
extern void mutex_lock(int mutex);
extern void mutex_unlock(int mutex);

extern void tskp_lock(void);
extern void tskp_unlock(void);

extern void tick_sleep(int tick);
extern void ssleep(int sec);
extern void msleep(int ms);



 
void gt_printf(const char *fmt, ...);
long gt_sprintf(char *buf ,const char *format,...);
long gt_snprintf(char *buf, U32 size, const char *fmt, ...);
void gt_printf_ext(const char *fmt, ...);



 
extern void gt_jump_app(U8 xUart);

#line 126 "..\\app\\APP\\gtlib.h"
#line 1 "..\\user\\..\\gtlib\\gtApp\\gtApp.h"





 




#line 1 "..\\app\\APP\\gtlib.h"

#line 195 "..\\app\\APP\\gtlib.h"

#line 12 "..\\user\\..\\gtlib\\gtApp\\gtApp.h"


 
#line 22 "..\\user\\..\\gtlib\\gtApp\\gtApp.h"



 



typedef const struct 
{
	void (*tsk)(void);				
	long long *stk;					
	int size;						
	char prio;						
	unsigned long  time_out;		
}Task_Config;						










 
extern void gt_tsk_deamon(void);









 
extern unsigned long gt_mbx_check(void * mailbox);










 












 
extern void gt_mbx_init(void * mailbox,u16   mbx_size );












 
extern unsigned long gt_mbx_send (void * mailbox,void* message_ptr,u16 timeout);















 
extern unsigned long gt_mbx_wait (void *  mailbox,void** message,u16  timeout);









 
extern void gt_mut_init(void *mutex);










 
extern unsigned long gt_mut_release(void *mutex);












 
extern unsigned long gt_mut_wait (void *mutex, unsigned short timeout);










 
extern void gt_sem_init (void * semaphore,u16 token_count );









 
extern unsigned long gt_sem_send (void * semaphore );












 
extern unsigned long gt_sem_wait (void * semaphore,u16 timeout );










 
extern void gt_evt_clr(unsigned short clear_flags,	unsigned long task_id);









 
extern unsigned short gt_evt_get(void);










 
extern void gt_evt_set(unsigned short event_flags,unsigned long task_id );











 
extern unsigned long  gt_evt_wait_and(unsigned short wait_flags,unsigned short timeout);












 
extern unsigned long  gt_evt_wait_or(unsigned short wait_flags,unsigned short timeout);










 
extern void gt_dly_wait(unsigned short delay);









 
extern void gt_itv_set(unsigned short delay);









 
extern void gt_itv_wait(void);









 
extern void gt_tsk_pass (void);









 
extern unsigned long gt_tsk_id(void);








 
extern void gt_tsk_lock(void);









 
extern void gt_tsk_unlock(void);












 
unsigned long gt_tsk_prio(char id, char prio);












 
unsigned long gt_tsk_prio_self(char prio);










 
char gt_tsk_self(void);











 
extern void gt_local_config(u8 *ip,u8 *mac);










 
extern void gt_net_select(u8 type,u8 soc);










 
extern void gt_remote_config(u8 *ip,u16 *port);











 
extern void gt_gprs_config(u8 *apn,u8 *user,u8 *password);









 
extern void gt_net_start(void);









 
extern void gt_net_stop(void);











 
extern void gt_net_config(int (*log)(),int (*pulse)(),int pulse_set);











 
extern void gt_server_cfg(int (*response)(const u8*,int,const u8**,int*),int type,int port);











 
extern int gt_net_senddata(const void *pData, int nLen);












 
extern int gt_net_recdata(void* pBuf,int size,int nTmo,int ntry);









 
extern int gt_gprs_signal(void);













 
extern int gt_netlog_state(void);















 
int gt_netstate_set(int new_state);





























 
int gt_net_step(void);









 
int gt_localip_get(char *ip);






 
#line 127 "..\\app\\APP\\gtlib.h"
#line 1 "..\\user\\..\\gtlib\\gtfs\\gtfs.h"










int  fs_io_Init(int index);
int  fs_io_format(void (*pCallback)());
int  fs_io_open(const char *name, const char *mode);
int  fs_io_write(const void *buffer,int size,int cnt,int fd);
int  fs_io_read(void *buffer,int size,int cnt,int fd);
int  fs_io_close(int fd);
int  fs_io_seek(int fd,long int offset,int whence);
int  fs_io_mkdir (const char *path);
int  fs_io_rm (const char *path);
int  fs_io_del(const char *path);
int  fs_io_rename (const char *oldpath,const char *newpath);
int  fs_io_list (const char *path);
long fs_io_len (int fd);
long fs_io_size (int fd);
long fs_io_sync (int fd);
int  fs_io_unlink (const char *name);
unsigned int fs_ffind (unsigned char code, unsigned char *buf, unsigned char *mask, unsigned int buflen);
int yaffs_io_close(int fp);


#line 46 "..\\user\\..\\gtlib\\gtfs\\gtfs.h"
	






#line 128 "..\\app\\APP\\gtlib.h"
#line 1 "..\\user\\..\\gtlib\\gtNet\\gtNet.h"
#line 2 "..\\user\\..\\gtlib\\gtNet\\gtNet.h"
#line 3 "..\\user\\..\\gtlib\\gtNet\\gtNet.h"

extern int net_main_cnt;
extern int net_tick_cnt;
extern int net_logic_cnt;
extern int net_server_cnt;


extern volatile int net_gprs_csq;






extern volatile int net_log_ste; 


extern volatile int net_run_step;

void gt_net_init(void);





int gt_net_open(U8 *remip, U16 remport,U16 locport,U8 type,char* dialNum,int timeout);
int gt_net_close(int soc);

int gt_net_state(int soc);

int gt_net_send(int soc, const void *pData, int nLen);
int gt_net_recv(int soc, void* pBuf,int size,int nTmo,int ntry);

void gt_net_mainTsk(void);
void gt_net_tickTsk(void);
void gt_net_logicTsk(void);
void gt_net_serverTsk(void);

void gt_netlog_cfg(int (*login)(),int (*link) (),int timeout);
void gt_netser_cfg(int (*response)(const U8*,int, const U8**,int*),int type,int port);
int gt_netser_send(void* tBuf,int tlen);

void gt_net_synch(char* dns,U8* pIP,U16 remport);

#line 56 "..\\user\\..\\gtlib\\gtNet\\gtNet.h"

int gt_net_set(int nID,void* pDat);
#line 129 "..\\app\\APP\\gtlib.h"
#line 1 "..\\user\\..\\gtlib\\gtUi\\gtui.h"




 





extern const  int  GUI_HZK_TYPE	;


extern const  int  GUI_HZK_BASE ;






extern const struct MenuItem MainMenu[];


extern const  int  DISP_TIME;		 
extern const  int  MENU_TIME;		 

extern const  int  GUI_HEAD_WIDTH  ;
extern const  int  GUI_LAST_WIDTH  ;


extern  const  int LCD_X_MAX ;
extern  const  int LCD_Y_MAX ;

extern const  int  GUI_HZK_TYPE	;

extern int GUI_ASC_WIDTH; 		  
extern int GUI_HZ_WIDTH; 		 
extern int GUI_HZ_HEIGHT;		
extern int GUI_HZ_SIZE;  


extern const  int  DISP_MAX_ROW  ;


extern const  int  DISP_ROW_SPACE;


extern const  int  DISP_START_X;


extern const  int  DISP_START_Y;


extern const  int  BG_TIME;

extern const  int  BACK_TO_LXTIME;

extern const  int  BACK_TO_MAINTIME;

extern const  int  LX_BACK_TIME;



extern const struct MenuItem *MenuPoint;





void disp_head(void);		  
void show_loopdisp(int);	  
void gui_set_time(unsigned long tTime);	  
unsigned gui_get_time(void);			  


typedef unsigned int		uint;
typedef signed char			sint8;
typedef unsigned char		uint8;
typedef short				sint16;
typedef unsigned short		uint16;
typedef int					sint32;
typedef unsigned int		uint32;
typedef long long			sint64;
typedef unsigned long long	uint64;
typedef unsigned char		bit;
typedef uint32				t_adr;
typedef int					t_color;

typedef const struct {
	uint nValue;		  
	const char *str;	  
}t_gui_spec_editor, *p_gui_spec_editor;


typedef  struct {
	uint16   ID;	  
	uint8 	 len;	  
}SysPa;


typedef union dataunion
{
	char 	strtmp[32];
	uint8 	u8tmp[8];
	uint32  u32tmp;
	uint32  u32temp[2];
	uint64	u64tmp;
}datatype;

typedef   unsigned char(*pExecFunDef)(datatype *pdata,int sel);	   
typedef   unsigned char(*pdisplay)(datatype *pdata,int sel,char change);	   
typedef   unsigned char(*pdisplays)(datatype *pdata,int sel,char change,uint8 nextpage);	
typedef struct
{
	uint16 mNum:8;				 
	uint16 reflash:4;			 
	pExecFunDef	funInit;		 
	pdisplays	funShow;		 
	pExecFunDef	funExec[32];     
}idxFunSts;

typedef struct
{
	uint16 mNum:8;				 
	uint16 reflash:4;			 
	pExecFunDef	funInit;		 
	pdisplay	funShow;		 
	pExecFunDef	funExec[32];     
}idxFunSt;



struct MenuItem
{
	unsigned char MenuCount; 
	unsigned char *p_reti;      
	unsigned char *DisplayString; 
	unsigned char (*Subs)(void *p); 
	void  *data;                                       
	const struct MenuItem *ChildrenMenus; 
	const struct MenuItem *ParentMenus; 
};






extern const struct MenuItem ProjectMenu[];


extern const  int  GUI_KEY_TYPE	;

extern const  int  GUI_LOCK_KEY	;

extern   int  GUI_LOCK_KEY_STATE;

extern const  int  GUI_LOCK_TIME ;


extern const  int KEY_CODE_UP	;		
extern const  int KEY_CODE_DOWN	;		
extern const  int KEY_CODE_LEFT ;   	
extern const  int KEY_CODE_RIGHT ; 		
extern const  int KEY_CODE_ESC	;		
extern const  int KEY_CODE_ENT	; 		
extern const  int KEY_CODE_LOCK ;		

extern int GUI_PRJ_KEY_NUM;

extern const unsigned char GUI_PRJ_KEY[];












int sprintf(char * __restrict  , const char * __restrict  , ...) __attribute__((__nonnull__(1,2)));









 
void gui_Init(void);













 
void gui_DrawLine(int x0, int y0, int x1, int y1, t_color color);				












 
void gui_DrawHLine(int x0, int y0, int x1, t_color color);












 
void gui_DrawRLine(int x0, int y0, int y1, t_color color);













 
void gui_DrawRect_Hol(int x1, int y1, int x2, int y2, t_color color);		













 
void gui_DrawRect_Fill(int x1, int y1, int x2, int y2, t_color color);			













 
void gui_DrawIcon_Mono(int x1, int y1, int x2, int y2, const unsigned char *p);









 
void gui_DrawBMP_Mono(unsigned char *p);













 
void gui_DrawString_ASC6x12(int x, int y, char *pStr, t_color nColor);  












 
void gui_DrawString_ASC6x8(int x, int y, char *pStr, t_color nColor); 












 
int gui_DrawString_Mixed(int x, int y, char *pStr, t_color nColor);     












 
void gui_DrawChar_HZ(int x, int y, char *pStr, t_color nColor);	        









 
int gui_GetStringWidth(char *pStr);	













 									
int gui_DrawString_Mixed_Align(int x, int y, char *pStr, t_color nColor, int nAlignType);         











 
void disp_SingleData_align(uint8 nRow, char *pData, int align_type);	












 
void disp_single_data(uint8 nRow, char *pItem, char *pData, t_color n_color); 












 
uint16 cycle(uint n, uint nStart, uint nEnd, int nStepping);











 
uint8 Get_NemuType(t_gui_spec_editor *p,uint n,uint j);












 
void gui_Editor_NumberCreate(char *pStr, uint64 nNum, uint nBits, int nBcd);










 
void gui_Editor_IPAddressCreate(char *pStr, uint8 *pIP);









 
unsigned char  Waitforkey(uint32 *ptmp);









 
unsigned char MenuExec(void *para);











 
unsigned char Set_Nemutype(datatype *pdata,t_gui_spec_editor *pitem,uint n);










 
unsigned char Edit_String(datatype *p,int num_bitAT);










 
unsigned char Edit_add(datatype *p,int num_bitAT);










 
unsigned char Set_IPAdr(datatype *p,int sel);











 
unsigned char Set_nBits(datatype *p,unsigned char bit,int nBCD);









 
unsigned char SetCurrentTime(void);











 
unsigned char Set_nNums2(datatype *p,unsigned char nArr,unsigned char ndata);










 
unsigned char Set_nNums(datatype *p,unsigned char nArr,unsigned char flag);











 
unsigned char Set_nNums3(datatype *p,unsigned char nArr,uint nBcd);










 
unsigned char Set_nNums4(datatype *p,unsigned char nArr);









 
void SetDispFlag(void);








 

#line 625 "..\\user\\..\\gtlib\\gtUi\\gtui.h"
#line 626 "..\\user\\..\\gtlib\\gtUi\\gtui.h"
#line 627 "..\\user\\..\\gtlib\\gtUi\\gtui.h"
#line 1 "..\\user\\..\\gtlib\\gtNet\\gtNet.h"
#line 2 "..\\user\\..\\gtlib\\gtNet\\gtNet.h"
#line 3 "..\\user\\..\\gtlib\\gtNet\\gtNet.h"

extern int net_main_cnt;
extern int net_tick_cnt;
extern int net_logic_cnt;
extern int net_server_cnt;


extern volatile int net_gprs_csq;






extern volatile int net_log_ste; 


extern volatile int net_run_step;

void gt_net_init(void);





int gt_net_open(U8 *remip, U16 remport,U16 locport,U8 type,char* dialNum,int timeout);
int gt_net_close(int soc);

int gt_net_state(int soc);

int gt_net_send(int soc, const void *pData, int nLen);
int gt_net_recv(int soc, void* pBuf,int size,int nTmo,int ntry);

void gt_net_mainTsk(void);
void gt_net_tickTsk(void);
void gt_net_logicTsk(void);
void gt_net_serverTsk(void);

void gt_netlog_cfg(int (*login)(),int (*link) (),int timeout);
void gt_netser_cfg(int (*response)(const U8*,int, const U8**,int*),int type,int port);
int gt_netser_send(void* tBuf,int tlen);

void gt_net_synch(char* dns,U8* pIP,U16 remport);

#line 56 "..\\user\\..\\gtlib\\gtNet\\gtNet.h"

int gt_net_set(int nID,void* pDat);
#line 628 "..\\user\\..\\gtlib\\gtUi\\gtui.h"
#line 1 "..\\user\\..\\gtlib\\gtUi\\gtui.h"
#line 629 "..\\user\\..\\gtlib\\gtUi\\gtui.h"
#line 630 "..\\user\\..\\gtlib\\gtUi\\gtui.h"

uint8   bcd2bin8(uint8  x);
uint8   bin2bcd8(uint8  x);
uint16 bin2bcd16(uint16 x);
uint16 bcd2bin16(uint16 x);
uint32 bin2bcd32(uint32 x);
uint32 bcd2bin32(uint32 x);
uint64 bin2bcd64(uint64 x);
uint64 bcd2bin64(uint64 x);

#line 648 "..\\user\\..\\gtlib\\gtUi\\gtui.h"

void TimeToBcd(U32 time, uint8 *dst);













 


#line 130 "..\\app\\APP\\gtlib.h"
#line 1 "..\\user\\..\\gtlib\\gtUi\\guiGetFont.h"







#line 9 "..\\user\\..\\gtlib\\gtUi\\guiGetFont.h"
#line 10 "..\\user\\..\\gtlib\\gtUi\\guiGetFont.h"
#line 11 "..\\user\\..\\gtlib\\gtUi\\guiGetFont.h"

extern U32 debugMark;


typedef struct
{
	U32 offset;
	U8 state;
	U8 data[32];

}font_buff_type;

extern int GUI_fp;	
extern const char* FontFileName;



extern int FontFile_mute;
extern void FontFile_initlock();
extern void FontFile_lock() ;
extern void FontFile_unlock() ;





int FontFileOpen();

void FontFileClose();






extern int GetFont(int pOffset , void *OutBuffer, char *font, int change);



extern void InitFont();



extern void CloseFont();





#line 131 "..\\app\\APP\\gtlib.h"
#line 132 "..\\app\\APP\\gtlib.h"

uint8   bcd2bin8(uint8  x);
uint8   bin2bcd8(uint8  x);
uint16 bin2bcd16(uint16 x);
uint16 bcd2bin16(uint16 x);
uint32 bin2bcd32(uint32 x);
uint32 bcd2bin32(uint32 x);
uint64 bin2bcd64(uint64 x);
uint64 bcd2bin64(uint64 x);

#line 150 "..\\app\\APP\\gtlib.h"

void TimeToBcd(U32 time, uint8 *dst);












extern void msg_trace(uint8* pDat,int len);















 

extern int ArrayBitSet(U8*buffer,int len,int index,U8 value);
extern int ArrayBitGet(U8*buffer,int len,int index);


extern int GMTToTime(const char* gmt,const U32 zone);




 




#line 6 "..\\app\\gt_alarm\\gt_alarm.c"
#line 7 "..\\app\\gt_alarm\\gt_alarm.c"
#line 8 "..\\app\\gt_alarm\\gt_alarm.c"
#line 1 "..\\app\\gt_alarm\\gt_alarm_int.h"



 
#line 1 "..\\app\\gt_alarm\\gt_alarm_cfg.h"



 





















 
#line 6 "..\\app\\gt_alarm\\gt_alarm_int.h"

#line 1 "..\\app\\APP\\store.h"








#line 10 "..\\app\\APP\\store.h"



typedef struct
{
	uint32 di;          
	uint16 group;		
	uint16 size;		
	uint16 offset;		
	uint16 ver_code;	
	uint8  save_type;	
	uint8  gat;         
	uint8* pVal;		
	uint8  r;
	uint8  w;
	uint8  rsv[6];		
}t_sysTable;






int gt_para_getIndex(U32 sno,U32 di,t_sysTable* pIdx);
int gt_para_process (U32 sno,U32 di,U8* pbuf,int len,U8 rw,U8 force);
int gt_grup_process (U32 sno,U32 di,U8 gat,U8* pbuf,int len,U8 rw,U8 force);
int gt_data_save(U8 force);
int gt_data_free(void);
void gt_store_init(void);


int gt_data_getIndex(U32 sno,U8 type,U32 di,t_sysTable* pIdx);
int gt_data_process (U32 sno,U8 type,U32 tn,U32 di,U8* pbuf,int len,U8 rw,U8 force);
int gt_dgrup_process (U32 sno,U8 type,U32 tn,U32 di,U8 gat,U8* pbuf,int len,U8 rw,U8 force);



#line 8 "..\\app\\gt_alarm\\gt_alarm_int.h"





















__packed typedef struct 
{
	U16 len;
	U16 tn;
	U8 report;
	U8 confirm;
}alarm_head;


__packed typedef struct 
{
	U32 code;
	U16 tn;
	U8 report;
	U8 confirm;
}alarm_index_type;





extern void *gt_malloc(int size);
extern void gt_free(void *p);
extern void *gt_realloc(void *p, int size);





 




#line 9 "..\\app\\gt_alarm\\gt_alarm.c"
#line 10 "..\\app\\gt_alarm\\gt_alarm.c"






 


























#pragma arm section rwdata = "SRAM",zidata = "SRAM"	  
static U8 alarm_state[(1001 * ((0x50 + 7) / 8))];		
static U16 al_state_crc[128];


static char alarm_cmp[10240];


static char alarm_0_data[500];
static char meter_fail[1001];

static char al_buff[10 * 512];	
static char alarm_buff[512];				
#pragma arm section

static U32 alarm_cmp_len = 0;
static U16 alarm_0_len = 0;

volatile static U32 alarm_state_chg = 0;

volatile static U8 alarm_file_lock = 0;

volatile static U8 alarm_happen = 0;

#line 1 "..\\app\\gt_alarm\\gt_alarm_item.c"



 
#line 6 "..\\app\\gt_alarm\\gt_alarm_item.c"
#line 7 "..\\app\\gt_alarm\\gt_alarm_item.c"
#line 8 "..\\app\\gt_alarm\\gt_alarm_item.c"
#line 1 "..\\app\\gt_alarm\\gt_alarm_int.h"



 
#line 1 "..\\app\\gt_alarm\\gt_alarm_cfg.h"



 





















 
#line 6 "..\\app\\gt_alarm\\gt_alarm_int.h"

#line 8 "..\\app\\gt_alarm\\gt_alarm_int.h"

#line 56 "..\\app\\gt_alarm\\gt_alarm_int.h"


 




#line 9 "..\\app\\gt_alarm\\gt_alarm_item.c"


#line 1 "..\\app\\gt_alarm\\gt_alarm_cfg.h"



 





















 
#line 12 "..\\app\\gt_alarm\\gt_alarm_item.c"
#line 1 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\math.h"




 





 












 








 






#line 48 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\math.h"

#line 62 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\math.h"

   




 















 
#line 93 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\math.h"











 





extern __softfp unsigned __ARM_dcmp4(double  , double  );
extern __softfp unsigned __ARM_fcmp4(float  , float  );
    




 

extern __declspec(__nothrow) __softfp int __ARM_fpclassifyf(float  );
extern __declspec(__nothrow) __softfp int __ARM_fpclassify(double  );
     
     

__inline __declspec(__nothrow) __softfp int __ARM_isfinitef(float __x)
{
    return (((*(unsigned *)&(__x)) >> 23) & 0xff) != 0xff;
}
__inline __declspec(__nothrow) __softfp int __ARM_isfinite(double __x)
{
    return (((*(1 + (unsigned *)&(__x))) >> 20) & 0x7ff) != 0x7ff;
}
     
     

__inline __declspec(__nothrow) __softfp int __ARM_isinff(float __x)
{
    return ((*(unsigned *)&(__x)) << 1) == 0xff000000;
}
__inline __declspec(__nothrow) __softfp int __ARM_isinf(double __x)
{
    return (((*(1 + (unsigned *)&(__x))) << 1) == 0xffe00000) && ((*(unsigned *)&(__x)) == 0);
}
     
     

__inline __declspec(__nothrow) __softfp int __ARM_islessgreaterf(float __x, float __y)
{
    unsigned __f = __ARM_fcmp4(__x, __y) >> 28;
    return (__f == 8) || (__f == 2);  
}
__inline __declspec(__nothrow) __softfp int __ARM_islessgreater(double __x, double __y)
{
    unsigned __f = __ARM_dcmp4(__x, __y) >> 28;
    return (__f == 8) || (__f == 2);  
}
    


 

__inline __declspec(__nothrow) __softfp int __ARM_isnanf(float __x)
{
    return (0x7f800000 - ((*(unsigned *)&(__x)) & 0x7fffffff)) >> 31;
}
__inline __declspec(__nothrow) __softfp int __ARM_isnan(double __x)
{
    unsigned __xf = (*(1 + (unsigned *)&(__x))) | (((*(unsigned *)&(__x)) == 0) ? 0 : 1);
    return (0x7ff00000 - (__xf & 0x7fffffff)) >> 31;
}
     
     

__inline __declspec(__nothrow) __softfp int __ARM_isnormalf(float __x)
{
    unsigned __xe = ((*(unsigned *)&(__x)) >> 23) & 0xff;
    return (__xe != 0xff) && (__xe != 0);
}
__inline __declspec(__nothrow) __softfp int __ARM_isnormal(double __x)
{
    unsigned __xe = ((*(1 + (unsigned *)&(__x))) >> 20) & 0x7ff;
    return (__xe != 0x7ff) && (__xe != 0);
}
     
     

__inline __declspec(__nothrow) __softfp int __ARM_signbitf(float __x)
{
    return (*(unsigned *)&(__x)) >> 31;
}
__inline __declspec(__nothrow) __softfp int __ARM_signbit(double __x)
{
    return (*(1 + (unsigned *)&(__x))) >> 31;
}
     
     








#line 211 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\math.h"



   
  typedef float float_t;
  typedef double double_t;







extern const int math_errhandling;



extern __declspec(__nothrow) double acos(double  );
    
    
    
extern __declspec(__nothrow) double asin(double  );
    
    
    
    

extern __declspec(__nothrow) __pure double atan(double  );
    
    

extern __declspec(__nothrow) double atan2(double  , double  );
    
    
    
    

extern __declspec(__nothrow) double cos(double  );
    
    
    
    
extern __declspec(__nothrow) double sin(double  );
    
    
    
    

extern void __use_accurate_range_reduction(void);
    
    

extern __declspec(__nothrow) double tan(double  );
    
    
    
    

extern __declspec(__nothrow) double cosh(double  );
    
    
    
    
extern __declspec(__nothrow) double sinh(double  );
    
    
    
    
    

extern __declspec(__nothrow) __pure double tanh(double  );
    
    

extern __declspec(__nothrow) double exp(double  );
    
    
    
    
    

extern __declspec(__nothrow) double frexp(double  , int *  ) __attribute__((__nonnull__(2)));
    
    
    
    
    
    

extern __declspec(__nothrow) double ldexp(double  , int  );
    
    
    
    
extern __declspec(__nothrow) double log(double  );
    
    
    
    
    
extern __declspec(__nothrow) double log10(double  );
    
    
    
extern __declspec(__nothrow) double modf(double  , double *  ) __attribute__((__nonnull__(2)));
    
    
    
    

extern __declspec(__nothrow) double pow(double  , double  );
    
    
    
    
    
    
extern __declspec(__nothrow) double sqrt(double  );
    
    
    




    __inline double _sqrt(double __x) { return sqrt(__x); }




    __inline float _sqrtf(float __x) { return (float)sqrt(__x); }

    



 

extern __declspec(__nothrow) __pure double ceil(double  );
    
    
extern __declspec(__nothrow) __pure double fabs(double  );
    
    

extern __declspec(__nothrow) __pure double floor(double  );
    
    

extern __declspec(__nothrow) double fmod(double  , double  );
    
    
    
    
    

    









 



extern __declspec(__nothrow) double acosh(double  );
    

 
extern __declspec(__nothrow) double asinh(double  );
    

 
extern __declspec(__nothrow) double atanh(double  );
    

 
extern __declspec(__nothrow) double cbrt(double  );
    

 
__inline __declspec(__nothrow) __pure double copysign(double __x, double __y)
    

 
{
    (*(1 + (unsigned *)&(__x))) = ((*(1 + (unsigned *)&(__x))) & 0x7fffffff) | ((*(1 + (unsigned *)&(__y))) & 0x80000000);
    return __x;
}
__inline __declspec(__nothrow) __pure float copysignf(float __x, float __y)
    

 
{
    (*(unsigned *)&(__x)) = ((*(unsigned *)&(__x)) & 0x7fffffff) | ((*(unsigned *)&(__y)) & 0x80000000);
    return __x;
}
extern __declspec(__nothrow) double erf(double  );
    

 
extern __declspec(__nothrow) double erfc(double  );
    

 
extern __declspec(__nothrow) double expm1(double  );
    

 



    

 






#line 445 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\math.h"


extern __declspec(__nothrow) double hypot(double  , double  );
    




 
extern __declspec(__nothrow) int ilogb(double  );
    

 
extern __declspec(__nothrow) int ilogbf(float  );
    

 
extern __declspec(__nothrow) int ilogbl(long double  );
    

 







    

 





    



 





    



 





    

 





    



 





    



 





    



 





    

 





    

 





    


 

extern __declspec(__nothrow) double lgamma (double  );
    


 
extern __declspec(__nothrow) double log1p(double  );
    

 
extern __declspec(__nothrow) double logb(double  );
    

 
extern __declspec(__nothrow) float logbf(float  );
    

 
extern __declspec(__nothrow) long double logbl(long double  );
    

 
extern __declspec(__nothrow) double nextafter(double  , double  );
    


 
extern __declspec(__nothrow) float nextafterf(float  , float  );
    


 
extern __declspec(__nothrow) long double nextafterl(long double  , long double  );
    


 
extern __declspec(__nothrow) double nexttoward(double  , long double  );
    


 
extern __declspec(__nothrow) float nexttowardf(float  , long double  );
    


 
extern __declspec(__nothrow) long double nexttowardl(long double  , long double  );
    


 
extern __declspec(__nothrow) double remainder(double  , double  );
    

 
extern __declspec(__nothrow) __pure double rint(double  );
    

 
extern __declspec(__nothrow) double scalbln(double  , long int  );
    

 
extern __declspec(__nothrow) float scalblnf(float  , long int  );
    

 
extern __declspec(__nothrow) long double scalblnl(long double  , long int  );
    

 
extern __declspec(__nothrow) double scalbn(double  , int  );
    

 
extern __declspec(__nothrow) float scalbnf(float  , int  );
    

 
extern __declspec(__nothrow) long double scalbnl(long double  , int  );
    

 




    

 



 
extern __declspec(__nothrow) __pure float _fabsf(float);  
__inline __declspec(__nothrow) __pure float fabsf(float __f) { return _fabsf(__f); }
extern __declspec(__nothrow) float sinf(float  );
extern __declspec(__nothrow) float cosf(float  );
extern __declspec(__nothrow) float tanf(float  );
extern __declspec(__nothrow) float acosf(float  );
extern __declspec(__nothrow) float asinf(float  );
extern __declspec(__nothrow) float atanf(float  );
extern __declspec(__nothrow) float atan2f(float  , float  );
extern __declspec(__nothrow) float sinhf(float  );
extern __declspec(__nothrow) float coshf(float  );
extern __declspec(__nothrow) float tanhf(float  );
extern __declspec(__nothrow) float expf(float  );
extern __declspec(__nothrow) float logf(float  );
extern __declspec(__nothrow) float log10f(float  );
extern __declspec(__nothrow) float powf(float  , float  );
extern __declspec(__nothrow) float sqrtf(float  );
extern __declspec(__nothrow) float ldexpf(float  , int  );
extern __declspec(__nothrow) float frexpf(float  , int *  ) __attribute__((__nonnull__(2)));
extern __declspec(__nothrow) __pure float ceilf(float  );
extern __declspec(__nothrow) __pure float floorf(float  );
extern __declspec(__nothrow) float fmodf(float  , float  );
extern __declspec(__nothrow) float modff(float  , float *  ) __attribute__((__nonnull__(2)));

 
 













 
__declspec(__nothrow) long double acosl(long double );
__declspec(__nothrow) long double asinl(long double );
__declspec(__nothrow) long double atanl(long double );
__declspec(__nothrow) long double atan2l(long double , long double );
__declspec(__nothrow) long double ceill(long double );
__declspec(__nothrow) long double cosl(long double );
__declspec(__nothrow) long double coshl(long double );
__declspec(__nothrow) long double expl(long double );
__declspec(__nothrow) long double fabsl(long double );
__declspec(__nothrow) long double floorl(long double );
__declspec(__nothrow) long double fmodl(long double , long double );
__declspec(__nothrow) long double frexpl(long double , int* ) __attribute__((__nonnull__(2)));
__declspec(__nothrow) long double ldexpl(long double , int );
__declspec(__nothrow) long double logl(long double );
__declspec(__nothrow) long double log10l(long double );
__declspec(__nothrow) long double modfl(long double  , long double *  ) __attribute__((__nonnull__(2)));
__declspec(__nothrow) long double powl(long double , long double );
__declspec(__nothrow) long double sinl(long double );
__declspec(__nothrow) long double sinhl(long double );
__declspec(__nothrow) long double sqrtl(long double );
__declspec(__nothrow) long double tanl(long double );
__declspec(__nothrow) long double tanhl(long double );





 
extern __declspec(__nothrow) float acoshf(float  );
__declspec(__nothrow) long double acoshl(long double );
extern __declspec(__nothrow) float asinhf(float  );
__declspec(__nothrow) long double asinhl(long double );
extern __declspec(__nothrow) float atanhf(float  );
__declspec(__nothrow) long double atanhl(long double );
__declspec(__nothrow) long double copysignl(long double , long double );
extern __declspec(__nothrow) float cbrtf(float  );
__declspec(__nothrow) long double cbrtl(long double );
extern __declspec(__nothrow) float erff(float  );
__declspec(__nothrow) long double erfl(long double );
extern __declspec(__nothrow) float erfcf(float  );
__declspec(__nothrow) long double erfcl(long double );
extern __declspec(__nothrow) float expm1f(float  );
__declspec(__nothrow) long double expm1l(long double );
extern __declspec(__nothrow) float log1pf(float  );
__declspec(__nothrow) long double log1pl(long double );
extern __declspec(__nothrow) float hypotf(float  , float  );
__declspec(__nothrow) long double hypotl(long double , long double );
extern __declspec(__nothrow) float lgammaf(float  );
__declspec(__nothrow) long double lgammal(long double );
extern __declspec(__nothrow) float remainderf(float  , float  );
__declspec(__nothrow) long double remainderl(long double , long double );
extern __declspec(__nothrow) float rintf(float  );
__declspec(__nothrow) long double rintl(long double );



#line 825 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\math.h"





#line 980 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\math.h"











#line 1182 "D:\\Keil\\ARM\\ARMCC\\bin\\..\\include\\math.h"



 

#line 13 "..\\app\\gt_alarm\\gt_alarm_item.c"


 


























typedef struct
{
	U32 id;
	U8 data_time;
}alarm_data_id;


typedef struct
{
	U32 code;
	U8  tn0;
	U8  total;
	U8  single;
	U8  three;
	int (*judge_func)(U16 tn, U32 state, U32 type, U8 *old_data);	
	const U32 *judge_id;
	U32 id_num;
	U32 item_num;	
	const alarm_data_id *list;
	int (*action)(U16 tn, U32 type);
	int (*undo_action)(U16 tn, U32 type);
	U8 state;
}alarm_type;



extern int gt_alarm_state(U32 code, U16 tn);
int GetAlarmCmpData(U16 tn, U32 id, void *dst);


const alarm_type alarm_list[];




const U32 meter_down_id[3] = 
{
	0x00010000, 0x00020000, 0xF1000000
};


const U32 meter_pro_id[1] = 
{
	0x03300000		
};

const U32 meter_rate_id[21] = 
{
	0x04000202,	
	0x04000203,	
	0x04000204,	
	0x04010000,	
	0x04010001,	
	0x04010002,	
	0x04010003,	
	0x04010004,	
	0x04010005,	
	0x04010006,	
	0x04010007,	
	0x04010008,	
	0x04020000,	
	0x04020001,	
	0x04020002,	
	0x04020003,	
	0x04020004,	
	0x04020005,	
	0x04020006,	
	0x04020007,	
	0x04020008,	
};

const U32 meter_ctpt_id[2] =
{
	0xE080000C,		
	0xE080000D,		
};

const U32 reverse_ia_id[2] = 
{
	0x1B010001,		
	0x1B010002,		
};

const U32 reverse_ib_id[2] = 
{
	0x1B020001,		
	0x1B020002,		
};

const U32 reverse_ic_id[2] = 
{
	0x1B030001,		
	0x1B030002,		
};

const U32 loss_ca_id[2] = 
{
	0x18010001,		
	0x18010002,		
};

const U32 loss_cb_id[2] = 
{
	0x18020001,		
	0x18020002,		
};

const U32 loss_cc_id[2] = 
{
	0x18030001,		
	0x18030002,		
};

const U32 loss_va_id[2] = 
{
	0x10010001,		
	0x10010002,		
};

const U32 loss_vb_id[2] = 
{
	0x10020001,		
	0x10020002,		
};

const U32 loss_vc_id[2] = 
{
	0x10030001,		
	0x10030002,		
};




const U32 meter_relay_id[1] = 
{
	0x04000503		
};

const U32 meter_prg_id[1] = 
{
	0x03300000		
};

const U32 meter_pulse_id[2] = 
{
	0xE1000003, 	
	0xE1000004, 	
};

const U32 need_clr_id[1] = 
{
	0x03300200		
};

const U32 meter_open1_id[1] = 
{
	0x03300E00		
};

const U32 meter_open2_id[1] = 
{
	0x03300D00		
};

const U32 phase_v_id[1] = 
{
	0xE1000030
};







 



const alarm_data_id ard2[9] = 
{
	0x00010000,	1,
	0x00020000,	1,
	0x00030000,	1,
	0x00040000,	1,
	0x0201FF00,	1,
	0x0202FF00,	1,
	0x0203FF00,	1,
	0x0204FF00,	1,
	0x0206FF00,	1,
};



const alarm_data_id ard3[16] = 
{
	0x00010000,	0,
	0x00020000,	0,
	0x00030000,	0,
	0x00040000,	0,
	0x0201FF00,	0,
	0x0202FF00,	0,
	0x0203FF00,	0,
	0x0204FF00,	0,
	
	0x00010000,	1,
	0x00020000,	1,
	0x00030000,	1,
	0x00040000,	1,
	0x0201FF00,	1,
	0x0202FF00,	1,
	0x0203FF00,	1,
	0x0204FF00,	1,	
};


const alarm_data_id ard4[5] = 
{
	0x00010000,	1,
	0x00020000,	1,
	0x00030000,	1,
	0x00040000,	1,
	0xE1000008, 1,	
};


const alarm_data_id ard5[8] = 
{
	0x00010000,	0,
	0x00020000,	0,
	0x00030000,	0,
	0x00040000,	0,
	0xE080000D, 0,
	0xE080000C, 0,
	
	0xE080000D, 1,
	0xE080000C, 1,	
};


const alarm_data_id ard6[8] = 
{
	0x00010000,	0,
	0x00020000,	0,
	0x00030000,	0,
	0x00040000,	0,
	0XE1000003, 0,
	0XE1000004, 0,

	0XE1000003, 1,
	0XE1000004, 1,
};


const alarm_data_id ard7[8] = 
{
	0x00010000,	0,
	0x00020000,	0,
	0x00030000,	0,
	0x00040000,	0,
	0X01010000, 0,	
	0X01020000, 0,	
	0X01030000, 0,	
	0X01040000, 0,	
};


const alarm_data_id ard8[2] = 
{
	0X040005FF, 0,
	0X040005FF, 1,
};


const alarm_data_id ard9[2] = 
{
	0XE0000C1F, 0,
	0XE0000C1F, 1,
};


const alarm_data_id ard10[1] = 
{
	0XE1800013, 1,
};


const alarm_data_id ard11[12] = 
{
	0x00010000,	0,
	0x00020000,	0,
	0x00050000,	0,
	0x00060000,	0,
	0x00070000,	0,
	0x00080000,	0,	

	0x00010000,	1,
	0x00020000,	1,
	0x00050000,	1,
	0x00060000,	1,
	0x00070000,	1,
	0x00080000,	1,	

};


const alarm_data_id ard12[1] = 
{
	0X04000503, 1,
};



const alarm_data_id ard13[3] = 
{
	0x04000101,	1,
	0x04000102, 1,
	0xE0000130, 1,
};



const alarm_data_id ard14[14] = 
{
	0X020A0100, 1,
	0X020A0200, 1,
	0X020A0300, 1,
	0X020B0100, 1,
	0X020B0200, 1,
	0X020B0300, 1,
	0XE1000101, 1,
	0XE1000102, 1,
	0XE1000103, 1,
	0XE1000104, 1,
	0XE1000105, 1,
	0XE100010D, 1,
	0XE100010E, 1,
	0XE100010F, 1,
};


const alarm_data_id ard15[1] = 
{
	0X03010000, 1,
};


const alarm_data_id ard16[1] = 
{
	0X030B0000, 1,
};


const alarm_data_id ard17[1] = 
{
	0X030E0000, 1,
};


const alarm_data_id ard18[1] = 
{
	0X03300000, 1,
};


const alarm_data_id ard21[1] = 
{
	0X00000000, 0,			
};


const alarm_data_id ard22[1] = 
{
	0X00000000, 0,			
};





 














 
int ReadChk(U16 tn, U32 id, void *dst, U32 size)
{
	U8 temp[32];
	
	if (gt_para_process(tn, id, (U8 *)dst, size, 'r', 0) != size)
		return 0;
	memset(temp, 0xFF, size);
	if (memcmp(dst, temp, size) == 0)
		return 0;
	return 1;
}













 
static int ChkMeterState(U16 tn, U32 chl, U32 bit)
{
	U32 data = 0;
	


	gt_para_process(tn, 0x04000504 + chl, (U8 *)&data, 2, 'r', 0);
	if (data & (1 << bit))
		return 1;
	return 0;
}














 
int AlMetterRelay(U16 tn, U32 state, U32 type, U8 *old_data)
{
	U16 data, temp;
	
	if (gt_para_process(tn, meter_relay_id[0], (U8 *)&data, 2, 'r', 0) != 1)
		return 0xFF;
	if (GetAlarmCmpData(tn, meter_relay_id[0], &temp) != 1)
		return 0xFF;
	if ((data & (1 << 4)) != (temp & (1 << 4)))
		return 1;
	return 0;
}	












 
int AlMetterTimeErr(U16 tn, U32 state, U32 type, U8 *old_data)
{
	struct tm t;
	int meter_time, sys_time, set;
	U8 data[8];
	U32 temp = 0;
	
	if (tn == 0)
		return 0;
	




	set = 0;
	gt_para_process(tn, 0xE0000188, (U8 *)(U8 *)&set, 1, 'r', 0);		
	if ((set == 0) || (set > 0x99))
		set = 10;
	if (gt_para_process(tn, 0x04000101, (U8 *)data, 4, 'r', 0) != 4)		
		return 0xFF;
	memcpy(&temp, data, 4);
	if (temp == 0 || temp == 0xFFFFFFFF)
		return 0xFF;
	if (gt_para_process(tn, 0x04000102, (U8 *)&data[4], 3, 'r', 0) != 3)	
		return 0xFF;
	temp = 0;
	memcpy(&temp, &data[4], 3);
	if (temp == 0 || temp == 0x00FFFFFF)
		return 0xFF;	
	t.tm_sec = bcd2bin8(data[4]);
	t.tm_min = bcd2bin8(data[5]);
	t.tm_hour = bcd2bin8(data[6]);
	t.tm_mday = bcd2bin8(data[1]);
	t.tm_mon = bcd2bin8(data[2]) - 1;
	t.tm_year = bcd2bin8(data[3]) + 100;
	meter_time = mktime(&t);
	sys_time = time(0);	
	if (sys_time >= meter_time)
	{
		if ((sys_time - meter_time) > 60 * set)
			return 1;
	}
	else
	{
		if ((meter_time - sys_time) > 60 * set)
			return 1;
	}
	return 0;
}














 
int AlMeterRateChg(U16 tn, U32 state, U32 type, U8 *old_data)
{
	t_sysTable info;
	U8 data[64], cmp[64], temp0[64], tempff[64];
	U32 i;
	
	memset(tempff, 0xFF, sizeof(tempff));
	memset(temp0, 0, sizeof(temp0));	
	for (i = 0; i < 21; i++)
	{
		if (gt_para_getIndex(tn, meter_rate_id[i], &info) != 1)
			continue;
		gt_para_process(tn, meter_rate_id[i], (U8 *)data, info . size, 'r', 0);
		if (memcmp(data, tempff, info.size) == 0)
			continue;
		if (memcmp(data, temp0, info.size) == 0)
			continue;		
		GetAlarmCmpData(tn, meter_rate_id[i], cmp);
		if (memcmp(cmp, tempff, info.size) == 0)
			continue;
		if (memcmp(cmp, temp0, info.size) == 0)
			continue;			
		if (memcmp(data, cmp, info.size) != 0)
			return 1;
	}
	return 0;
}














 
int AlMeterProChg(U16 tn, U32 state, U32 type, U8 *old_data)
{
	U32 data, temp;
	
	data = 0;
	if (gt_para_process(tn, meter_pro_id[0], (U8 *)&data, 3, 'r', 0) != 3)
		return 0xFF;
	if (data > 0x00999999)
		return 0xFF;	
	temp = 0;
	if (GetAlarmCmpData(tn, meter_pro_id[0], &temp) != 1)
		return 0xFF;
	if (temp > 0x00999999)
		return 0xFF;	
	if (temp != data)
		return 1;
	return 0;
}















 
int AlBatLow(U16 tn, U32 state, U32 type, U8 *old_data)
{
	int data;
	
	if (tn == 0)
	{
		return 0xFF;
	}
	else
	{
		data = 0;
		if (gt_para_process(tn, 0x04000501, (U8 *)&data, 2, 'r', 0) != 2)		
			return 0xFF;

		

		if ((data & 4) == 4)
			return 1;	
	}

	

	return 0;
}












 
int AlMeterCtPtChg(U16 tn, U32 state, U32 type, U8 *old_data)
{
	U16 new_data, old;
	U32 i, ct = 0;
	
	for (i = 0; i < 2; i++)
	{
		if (gt_para_process(tn, meter_ctpt_id[i], (U8 *)&new_data, 2, 'r', 0) != 2)
			continue;
		if (new_data == 0x0000FFFF)
			continue;
		if (GetAlarmCmpData(tn, meter_ctpt_id[i], &old) != 1)
			continue;
		if (old == 0x0000FFFF)
			continue;
		if (new_data != old)
			return 1;
		ct++;
	}
	if (ct == 2)
		return 0;
	return 0xFF;
}












 
int AlMeterPulseChg(U16 tn, U32 state, U32 type, U8 *old_data)
{
	int new_data, old, i;
	
	for (i = 0; i < 2; i++)
	{
		new_data = 0;
		old = 0;
		if (gt_para_process(tn, meter_pulse_id[i], (U8 *)&new_data, 3, 'r', 0) != 3)
			continue;
		if (new_data == 0x00FFFFFF)
			continue;
		if (GetAlarmCmpData(tn, meter_pulse_id[i], &old) != 1)
			continue;
		if (old == 0x00FFFFFF)
			continue;
		if (new_data != old)
			return 1;
	}		
	return 0;
}













 
int AlCtOpenA(U16 tn, U32 state)
{

	return 0;
}










 
int AlCtOpenB(U16 tn, U32 state)
{

	return 0;
}










 
int AlCtOpenC(U16 tn, U32 state)
{

	return 0;
}










 
int AlCtShortA(U16 tn, U32 state)
{

	return 0;
}










 
int AlCtShortB(U16 tn, U32 state)
{

	return 0;
}










 
int AlCtShortC(U16 tn, U32 state)
{

	return 0;
}













 
int AlMeterStop(U16 tn, U32 state, U32 type, U8 *old_data)
{
	#pragma arm section rwdata = "SRAM",zidata = "SRAM"	   
	static float eq_add[1001] = {0};
	#pragma arm section
	static U16 init = 0x2562;
	float cal_eq = 0;
	float set, p;
	int data, temp, i;
	
	if (init == 0x2562)
	{
		for (i = 0; i < 1001; i++)
		eq_add[i] = 0;
	}
	init = 0;	
	if (tn == 0)
		return 0;


	for (i = 0; i < 2; i++)
	{
		gt_para_process(tn, meter_down_id[i], (U8 *)&data, 4, 'r', 0);
		if (data > 0x99999999)
		{
			eq_add[tn] = 0;
			return 0xFF;
		}
		if (GetAlarmCmpData(tn, meter_down_id[i], &temp) != 1)
			return 0xFF;
		if (temp > 0x99999999)
		{
			eq_add[tn] = 0;
			return 0xFF;
		}
		if (data != temp)
		{
			eq_add[tn] = 0;
			return 0;
		}
	}
	if (state == 1)
	{
		eq_add[tn] = 0;
		return 0xFF;
	}
	data = 0;
	gt_para_process(tn, 0x02030000, (U8 *)&data, 3, 'r', 0);					
	if (data > 0x00999999)
	{
		eq_add[tn] = 0;
		return 0xFF;
	}
	data = bcd2bin32(data);
	p = (float)data / 10000;
	gt_para_process(tn, 0xF1000000, (U8 *)&data, 4, 'r', 0);
	if (data == 0 || data == 0xFFFFFFFF)
	{
		eq_add[tn] = 0;
		return 0xFF;
	}
	if (GetAlarmCmpData(tn, meter_down_id[2], &temp) != 1)
		return 0xFF;
	if (temp == 0 || temp == 0xFFFFFFFF)
	{
		eq_add[tn] = 0;
		return 0xFF;
	}	
	if (temp > data)
	{
		eq_add[tn] = 0;
		return 0xFF;
	}
	else if ((data - temp) >  10 * 60 * 1000)		
	{
		eq_add[tn] = 0;
		return 0xFF;
	}		
	cal_eq = p * (data - temp) / 3600;	
	eq_add[tn] += cal_eq;
	data = 0;
	gt_para_process(0, 0xE000018A, (U8 *)&data, 2, 'r', 0);					
	if (data > 0x00009999 || data == 0)
		data = 0x0010;				
	data = bcd2bin16(data);
	set = (float)data / 100;
	if (eq_add[tn] >= set)
	{
		eq_add[tn] = 0;
		return 1;
	}
	return 0;
}















 
int AlNeedClr(U16 tn, U32 state, U32 type, U8 *old_data)
{
	U32 data, old;
	
	data = 0;
	if (gt_para_process(tn, need_clr_id[0], (U8 *)&data, 3, 'r', 0) != 3)
		return 0xFF;
	if (data == 0x00FFFFFF)
		return 0xFF;
	old = 0;
	if (GetAlarmCmpData(tn, need_clr_id[0], &old) != 1)
		return 0xFF;
	if (old == 0x00FFFFFF)
		return 0xFF;	
	if (old != data)
		return 1;
	return 0;
}
















 
int AlMeterAccount(U16 tn, U32 state, U32 type, U8 *old_data)
{
	int data, temp;
	
	if (gt_para_process(tn, 0x00900200, (U8 *)&data, 4, 'r', 0) != 4)		
		return 0xFF;
	if (data > 0x99999999)
		return 0xFF;
	temp = 0;
	if (gt_para_process(0, 0xE000018B, (U8 *)&temp, 3, 'r', 0) != 3)		
		temp = 0x2000;			
	if (temp == 0 || temp > 0x00999999)
		temp = 0x2000;			

	

	if (data < temp)
		return 1;
	return 0;
}














 
int AlMeterDown(U16 tn, U32 state, U32 type, U8 *old_data)
{
	int data, temp, i;
	
	if (tn == 0)
		return 0;


	for (i = 0; i < 2; i++)
	{
		gt_para_process(tn, meter_down_id[i], (U8 *)&data, 4, 'r', 0);
		if (data == 0xFFFFFFFF)
			continue;
		if (GetAlarmCmpData(tn, meter_down_id[i], &temp) != 1)
			return 0xFF;
		if (temp == 0xFFFFFFFF)
			continue;
		if (data < temp)
		{
			if ((data < 0x100000) && (temp > 0x99900000))
				return 0;
			return 1;
		}
	}
	return 0;
}














 
typedef __packed struct
{
	U32 id;
	U16 tn1;
	U16 tn2;
	U8	min[3];
	U16	rr;
	U16 ss;
}eq_diff_type;

typedef __packed struct
{
	U32 tn1_init;
	U32 tn2_init;
	U8 state;
}eq_diff_data_type;




int AlEqDiff(U16 tn, U32 state, U32 type, U8 *old_data)
{

	t_sysTable info;
#pragma arm section rwdata = "SRAM",zidata = "SRAM"	  

	static eq_diff_data_type eq_data[2];
#pragma arm section
	static int start = 35;
	eq_diff_type para;
	U32 data, i, threshold;
	float f1, f2;
	U8 num, enable[32];
	U8 diff_state[32];
		
	if (start == 35)
	{
		memset(eq_data, 0, sizeof(eq_data));
	}
	start = 1;	
	if (gt_para_process(0, 0xE0000800, (U8 *)&num, 1, 'r', 0) != 1)
		return 0xFF;
	if (num > 99 || num == 0)
		return 0xFF;
	if (gt_para_process(0, 0xE00008FE, (U8 *)enable, 32, 'r', 0) != 32)
		return 0xFF;	
	if (num > 2)
	{
		gt_printf("\neq_diff too many: %d", num);		
		num = 2;
	}
	if (gt_para_process(0, 0xF0002000, (U8 *)diff_state, 32, 'r', 0) != 32)
		return 0xFF;




	for (i = 0; i < num; i++)
	{
		if (GetBit(enable, i) == 0)
		{	
			eq_data[i].tn1_init = 0;
			eq_data[i].tn2_init = 0;
			eq_data[i].state = 0;
			bitClr((uint32*)(diff_state),(i));
			continue;
		}
		if (gt_para_process(0, 0xE0000801 + i, (U8 *)&para, sizeof(eq_diff_type), 'r', 0) != sizeof(eq_diff_type))
			continue;
		if (para.tn2 != tn)
			continue;
		switch (eq_data[i].state)
		{
			case 0: 
				if (gt_para_getIndex(para . tn1, para . id, &info) != 1) 
					break;
				gt_para_process(para . tn1, para . id, (U8 *)&eq_data[i]. tn1_init, info . size, 'r', 0);			
				eq_data[i].tn1_init = bcd2bin32(eq_data[i].tn1_init);
				if (gt_para_getIndex(para . tn2, para . id, &info) != 1) 
					break;  
				gt_para_process(para . tn2, para . id, (U8 *)&eq_data[i]. tn2_init, info . size, 'r', 0);	
				eq_data[i].tn2_init = bcd2bin32(eq_data[i].tn2_init);
				eq_data[i].state = 1;

				gt_printf("\neq diff %d start : %d, %d", i + 1, eq_data[i].tn1_init, eq_data[i].tn2_init);

				bitClr((uint32*)(diff_state),(i));
				break;
				
			case 1:
				data = 0;
				gt_para_process(para . tn1, para . id, (U8 *)&data, 4, 'r', 0);
				data = bcd2bin32(data);
				if (data > eq_data[i].tn1_init)				
					data -= eq_data[i].tn1_init;
				else 
					data = eq_data[i].tn1_init - data;
				threshold = 0;
				memcpy(&threshold, para.min, 3);
				threshold = bcd2bin32(threshold);

				gt_printf("\n%d: %d, %d", i + 1, data, threshold);

				if (data < threshold)
					break;
				
				f1 = data;
				data = 0;
				gt_para_process(para . tn2, para . id, (U8 *)&data, 4, 'r', 0);
				data = bcd2bin32(data);

				gt_printf("\n tn2 %d", data);

				if (data > eq_data[i].tn2_init)
					data -= eq_data[i].tn2_init;	
				else 
					data = eq_data[i].tn2_init - data;

				gt_printf(" %d", data);

				f2 = data;
				if (f1 > f2)
					f1 = (f1 - f2) / f1;
				else
					f1 = (f2 - f1) / f1;
				data = f1 * 10000;	

				gt_printf("/ %d, %X, %X", data, para.rr, para.ss);

				if (GetBit(diff_state, i) == 0)
				{
					if (data > bcd2bin32(para.rr))
					{	
						gt_alarm_save(0xE2000030, para.tn2, 1);	
						bitSet((uint32*)(diff_state),(i));
					}
				}
				else
				{
					if (data < bcd2bin32(para.ss))
					{
						gt_alarm_save(0xE2000030, para.tn2, 0);		
						bitClr((uint32*)(diff_state),(i));
					}
				}
				
				gt_para_process(para . tn1, para . id, (U8 *)&eq_data[i]. tn1_init, 4, 'r', 0);
				eq_data[i].tn1_init = bcd2bin32(eq_data[i].tn1_init);
				gt_para_process(para . tn2, para . id, (U8 *)&eq_data[i]. tn2_init, 4, 'r', 0);
				eq_data[i].tn2_init = bcd2bin32(eq_data[i].tn2_init);
				eq_data[i].state = 1;
				break;
			
			default:
				eq_data[i].state = 0;
				eq_data[i].tn1_init = 0;
				eq_data[i].tn2_init = 0;
				break;
		}	
	}
	gt_para_process(0, 0xF0002000, (U8 *)diff_state, 32, 'w', 0);
	return 0xFF;
}	
	











 
int AlMeterOpen1(U16 tn, U32 state, U32 type, U8 *old_data)
{
	int data, temp;
	
	data = 0;
	if (gt_para_process(tn, meter_open1_id[0], (U8 *)&data, 3, 'r', 0) != 3)
		return 0xFF;
	if (data == 0x00FFFFFF)
		return 0xFF;
	temp = 0;
	if (GetAlarmCmpData(tn, meter_open1_id[0], &temp) != 1)
		return 0xFF;
	if (temp == 0x00FFFFFF)
		return 0xFF;

	

	if (data != temp)
		return 1;
	return 0;
}













 
int AlMeterOpen2(U16 tn, U32 state, U32 type, U8 *old_data)
{
	int data, temp;
	
	data = 0;
	if (gt_para_process(tn, meter_open2_id[0], (U8 *)&data, 3, 'r', 0) != 3)
		return 0xFF;
	if (data == 0x00FFFFFF)
		return 0xFF;
	temp = 0;
	if (GetAlarmCmpData(tn, meter_open2_id[0], &temp) != 1)
		return 0xFF;
	if (temp == 0x00FFFFFF)
		return 0xFF;

	

	if (data != temp)
		return 1;
	return 0;
}












 
int AlLossVA(U16 tn, U32 state, U32 type, U8 *old_data)
{
	return AlReverseC(tn, loss_va_id, old_data);
}










 
int AlLossVB(U16 tn, U32 state, U32 type, U8 *old_data)
{	
	return AlReverseC(tn, loss_vb_id, old_data);
}










 
int AlLossVC(U16 tn, U32 state, U32 type, U8 *old_data)
{
	return AlReverseC(tn, loss_vc_id, old_data);
}










 
int AlLossV(U16 tn, U32 state, U32 type, U8 *old_data)
{
	int i;
	
	for (i = 0; i < 3; i++)
	{
		if (gt_alarm_state(0xE2000016 + i, tn) == 0)
			return 0;
	}
	return 1;
}










 
int AlLossCA(U16 tn, U32 state, U32 type, U8 *old_data)
{
	return AlReverseC(tn, loss_ca_id, old_data);
}










 
int AlLossCB(U16 tn, U32 state, U32 type, U8 *old_data)
{
	return AlReverseC(tn, loss_cb_id, old_data);
}










 
int AlLossCC(U16 tn, U32 state, U32 type, U8 *old_data)
{
	return AlReverseC(tn, loss_cc_id, old_data);
}














 
int AlPhaseVA(U16 tn, U32 state, U32 type, U8 *old_data)
{
	return ChkMeterState(tn, 0, 7);
}













 
int AlPhaseVB(U16 tn, U32 state, U32 type, U8 *old_data)
{
	return ChkMeterState(tn, 1, 7);
}













 
int AlPhaseVC(U16 tn, U32 state, U32 type, U8 *old_data)
{
	return ChkMeterState(tn, 2, 7);
}













 
int AlOverVA(U16 tn, U32 state, U32 type, U8 *old_data)
{
	return ChkMeterState(tn, 0, 2);
}












 
int AlOverVB(U16 tn, U32 state, U32 type, U8 *old_data)
{
	return ChkMeterState(tn, 1, 2);
}













 
int AlOverVC(U16 tn, U32 state, U32 type, U8 *old_data)
{
	return ChkMeterState(tn, 2, 2);
}













 














































































































 
int AlOverCA(U16 tn, U32 state, U32 type, U8 *old_data)
{
	return ChkMeterState(tn, 0, 4);
}












 
int AlOverCB(U16 tn, U32 state, U32 type, U8 *old_data)
{
	return ChkMeterState(tn, 1, 4);
}













 
int AlOverCC(U16 tn, U32 state, U32 type, U8 *old_data)
{
	return ChkMeterState(tn, 2, 4);
}
















 
int AlMeterOverLoad(U16 tn, U32 state, U32 type, U8 *old_data)
{
	U32 data, now;
	float set, p;
	static U32 time_ct = 0;
	


	data = 0;
	if (gt_para_process(tn, 0x02050000, (U8 *)&data, 3, 'r', 0) != 3)		
		return 0xFF;		
	if (data == 0x00FFFFFF)
		return 0xFF;
	data = bcd2bin32(data);
	p = (float)data / 10000;
	data = 0;
	if (gt_para_process(tn, 0xE0800013, (U8 *)&data, 2, 'r', 0) != 2)		
		return 0xFF;
	if (data == 0 || data == 0x0000FFFF)
		return 0xFF;
	data = bcd2bin16(data);
	set = (float)data / 100;
	data = 0;
	now = time(0);
	if (state == 0)
	{
		if (gt_para_process(0, 0xE0800105, (U8 *)&data, 2, 'r', 0) != 2)		
			return 0xFF;
		if (data == 0 || data == 0x0000FFFF)
			return 0xFF;
		data = bcd2bin16(data);
		set *= ((float)data / 100);
		if (p <= set)
		{
			time_ct = 0;
			return 0;
		}
		if (time_ct == 0)
		{
			time_ct = now;
			return 0;
		}
		if (now < time_ct)
		{
			time_ct = now;
			return 0;
		}			
		data = 0;
		if (gt_para_process(0, 0xE0000180, (U8 *)&data, 1, 'r', 0) != 1)
		{
			time_ct = 0;
			return 0xFF;
		}
		if (data == 0xFF || data == 0)
		{
			time_ct = 0;
			return 0xFF;
		}
		data = bcd2bin8(data);
		if (now - time_ct >= data * 60)
		{
			time_ct = 0;
			return 1;			
		}
		return 0;
	}
	else
	{
		if (gt_para_process(0, 0xE0800106, (U8 *)&data, 2, 'r', 0) != 2)		
			return 0xFF;
		if (data == 0 || data == 0x0000FFFF)
			return 0xFF;	
		data = bcd2bin16(data);
		set *= ((float)data / 100);	
		if (p >= set)
		{
			time_ct = 0;
			return 1;
		}
		if (time_ct == 0)
		{
			time_ct = now;
			return 1;
		}
		if (now < time_ct)
		{
			time_ct = now;
			return 1;
		}			
		
		data = 0;
		if (gt_para_process(0, 0xE0000181, (U8 *)&data, 1, 'r', 0) != 1)
		{
			time_ct = 0;
			return 0xFF;
		}
		if (data == 0xFF || data == 0)
		{
			time_ct = 0;
			return 0xFF;
		}
		data = bcd2bin8(data);

		if (now - time_ct >= data * 60)
		{
			time_ct = 0;
			return 0;			
		}
		return 1;			
	}		
}












 
static int AlReverseC(U16 tn, const U32 *id, U8 *old_data)
{
	U32 data, temp, i;
	
	for (i = 0; i < 2; i++)
	{
		data = 0xFFFFFFFF;
		gt_para_process(tn, id[i], (U8 *)&data, 3, 'r', 0);
		if (data == 0xFFFFFFFF)
			return 0xFF;
		temp = 0xFFFFFFFF;
		if (GetAlarmCmpData(tn, id[i], &temp) != 1)
			return 0xFF;
		if (temp == 0xFFFFFFFF)
			return 0xFF;
		if (temp != data)
			return 1;
	}
	return 0;
}













 
int AlReverseCA(U16 tn, U32 state, U32 type, U8 *old_data)
{
	return AlReverseC(tn, reverse_ia_id, old_data);
}














 
int AlReverseCB(U16 tn, U32 state, U32 type, U8 *old_data)
{
	return AlReverseC(tn, reverse_ib_id, old_data);
}













 
int AlReverseCC(U16 tn, U32 state, U32 type, U8 *old_data)
{
	return AlReverseC(tn, reverse_ic_id, old_data);
}










 
static ChkI(U16 tn, float x)
{
	U32 now;
	U32 in; 
	float f_in, i[3];
	U8 set;
	
	in = 0;
	if (gt_para_process(tn, 0xE0800012, (U8 *)&in, 3, 'r', 0) != 3)		
		return 0xFF;
	if (in == 0 || in > 0x999999)
		return 0xFF;
	in = bcd2bin32(in);
	f_in = (float)in / 1000;
	now = 0;
	for (set = 0; set < 3; set++)
	{
		gt_para_process(tn, 0x02020100 + set * 0x100, (U8 *)&now, 3, 'r', 0);
		now = bcd2bin32(now);
		i[set] = (float)now / 1000;
	}
	i[0] = (i[0] + i[1] + i[2]) / 3;
	if (i[0] < f_in * 0.2)
		return 0xFF;
	return 1;
}













 
int AlMeterEpLess(U16 tn, U32 state, U32 type, U8 *old_data)
{
	static U32 time_ct = 0;
	U16 cos, cos_set;
	U32 now;
	U8 set;
	
	if (ChkI(tn, 0.2) != 1)
		return 0xFF;


	if (gt_para_process(tn, 0x02060000, (U8 *)&cos, 2, 'r', 0) != 2)	
		return 0xFF;
	if (cos > 0x1000)
		return 0xFF;
	if (gt_para_process(tn, 0x04000501, (U8 *)&state, 2, 'r', 0) != 2)	
		return 0xFF;
	if (state & (1 << 4))					
		return 0xFF;
	
	
	if (state == 0)
	{
		if (state & (1 << 5) == 1)
			return 0xFF;
		if (gt_para_process(0, 0xE080020D, (U8 *)&cos_set, 2, 'r', 0) != 2)	
			cos_set = 0x0800;
		if (cos_set > 0x1000)
			cos_set = 0x0800;
		if (cos >= cos_set)
		{
			time_ct = 0;
			return 0xFF;
		}	
		now = time(0);
		if (time_ct == 0)
		{
			time_ct = now;
			return 0xFF;
		}
		if (now < time_ct)
		{
			time_ct = now;
			return 0xFF;
		}
		if (gt_para_process(0, 0xE0000180, (U8 *)&set, 1, 'r', 0) != 1)	
			set = 0x15;
		if (set == 0 || set > 0x99)
			set = 0x15;
		set = bcd2bin8(set);		
		if (now - time_ct < set * 60)
			return 0xFF;
		time_ct = 0;
		return 1;
	}
	else
	{


		if (gt_para_process(0, 0xE080020E, (U8 *)&cos_set, 2, 'r', 0) != 2)	
			cos_set = 0x0900;
		if (cos_set > 0x1000)
			cos_set = 0x0900;
		if (cos < cos_set)
		{
			time_ct = 0;
			return 0xFF;
		}	
		now = time(0);
		if (time_ct == 0)
		{
			time_ct = now;
			return 0xFF;
		}
		if (now < time_ct)
		{
			time_ct = now;
			return 0xFF;
		}
		if (gt_para_process(0, 0xE0000181, (U8 *)&set, 1, 'r', 0) != 1)	
			set = 0x15;
		if (set == 0 || set > 0x99)
			set = 0x15;
		set = bcd2bin8(set);		
		if (now - time_ct < set * 60)
			return 0xFF;
		time_ct = 0;
		return 0;

	}
	return 0xFF;
}













 
int AlMeterEpOver(U16 tn, U32 state, U32 type, U8 *old_data)
{
	static U32 time_ct = 0;
	U16 cos, cos_set;
	U32 now;
	U8 set;
	
	if (ChkI(tn, 0.2) != 1)
		return 0xFF;


	if (gt_para_process(tn, 0x02060000, (U8 *)&cos, 2, 'r', 0) != 2)	
		return 0xFF;
	if (cos > 0x1000)
		return 0xFF;
	if (gt_para_process(tn, 0x04000501, (U8 *)&state, 2, 'r', 0) != 2)	
		return 0xFF;
	if (state & (1 << 4))					
		return 0xFF;
	
	if (state == 0)
	{
		if (state & (1 << 5) == 0)
			return 0xFF;
		if (gt_para_process(0, 0xE080020D, (U8 *)&cos_set, 2, 'r', 0) != 2)	
			cos_set = 0x0800;
		if (cos_set > 0x1000)
			cos_set = 0x0800;
		if (cos >= cos_set)
		{
			time_ct = 0;
			return 0xFF;
		}	
		now = time(0);
		if (time_ct == 0)
		{
			time_ct = now;
			return 0xFF;
		}
		if (now < time_ct)
		{
			time_ct = now;
			return 0xFF;
		}
		if (gt_para_process(0, 0xE0000180, (U8 *)&set, 1, 'r', 0) != 1)	
			set = 0x15;
		if (set == 0 || set > 0x99)
			set = 0x15;
		set = bcd2bin8(set);		
		if (now - time_ct < set * 60)
			return 0xFF;
		time_ct = 0;
		return 1;
	}
	else
	{


		if (gt_para_process(0, 0xE080020E, (U8 *)&cos_set, 2, 'r', 0) != 2)	
			cos_set = 0x0900;
		if (cos_set > 0x1000)
			cos_set = 0x0900;
		if (cos < cos_set)
		{
			time_ct = 0;
			return 0xFF;
		}	
		now = time(0);
		if (time_ct == 0)
		{
			time_ct = now;
			return 0xFF;
		}
		if (now < time_ct)
		{
			time_ct = now;
			return 0xFF;
		}
		if (gt_para_process(0, 0xE0000181, (U8 *)&set, 1, 'r', 0) != 1)	
			set = 0x15;
		if (set == 0 || set > 0x99)
			set = 0x15;
		set = bcd2bin8(set);		
		if (now - time_ct < set * 60)
			return 0xFF;
		time_ct = 0;
		return 0;

	}
	return 0xFF;
}















 
int AlGprsFlowOver(U16 tn, U32 state)
{

	return 0;
}






extern int EvLossVAS(U16 tn, U32 type);

extern int EvLossVAE(U16 tn, U32 type);

extern int EvLossVBS(U16 tn, U32 type);

extern int EvLossVBE(U16 tn, U32 type);

extern int EvLossVCS(U16 tn, U32 type);

extern int EvLossVCE(U16 tn, U32 type);


extern int EvLossCAS(U16 tn, U32 type);

extern int EvLossCAE(U16 tn, U32 type);

extern int EvLossCBS(U16 tn, U32 type);

extern int EvLossCBE(U16 tn, U32 type);

extern int EvLossCCS(U16 tn, U32 type);

extern int EvLossCCE(U16 tn, U32 type);


extern int EvPhaseAS(U16 tn, U32 type);

extern int EvPhaseAE(U16 tn, U32 type);

extern int EvPhaseBS(U16 tn, U32 type);

extern int EvPhaseBE(U16 tn, U32 type);

extern int EvPhaseCS(U16 tn, U32 type);

extern int EvPhaseCE(U16 tn, U32 type);


extern int EvNeedClr(U16 tn, U32 type);


extern int EvOpen1(U16 tn, U32 type);


extern int EvOpen2(U16 tn, U32 type);



















#line 2333 "..\\app\\gt_alarm\\gt_alarm_item.c"


const alarm_type alarm_list[21] = 
{
	
  	{0xE200002C, 	0,	1,	1,	1,	AlMeterDown	, meter_down_id,	2,	16,	ard3,	0,		0,	0},		
   	{0xE200002E, 	0,	1,	1,	1,	AlMeterStop	, meter_down_id,	3,	9,	ard2,	0,		0,	0},		
  	{0xE2000035, 	0,	1,	0,	1,	AlMeterProChg,	meter_pro_id, 	1,	9,	ard2,	0,		0,	0},		
  	{0xE2000036, 	0,	1,	1,	1,	AlMeterRateChg,	meter_rate_id, 	21,		0,		0,		0,		0,	0},		
	{0xE200003E,	0,	1,	1,	1,	AlMetterTimeErr,	0,			0,	3,	ard13,	0,		0,	0},		
};










 



#line 68 "..\\app\\gt_alarm\\gt_alarm.c"


int ChkAlarmState(U32 offset, U32 file_lock);
U16 cs16(const U8 *p, U32 nLength);









 
static int AlarmFileLock(int tick)
{
	while (tick--)
	{
		gt_tsk_lock();
		if (alarm_file_lock == 0)
		{
			alarm_file_lock = 1;
			gt_tsk_unlock();
			return 1;
		}
		gt_tsk_unlock();
		gt_dly_wait(1);
	}

	if((debugMark & 1)==0){
	gt_printf("\nlock alarm file fail");
		}

	return 0;
}










 
static int AlarmFileUnlock()
{

	alarm_file_lock = 0;

	return 1;
}











 
static int GetBit(const void *data, int bit)
{
	int i, j;
	char *p = (void *)data;
	
	i = bit / 8;
	j = bit % 8;
	return ((p[i] >> j) & 1);
}











 
static U16 cs16(const U8 *p, U32 nLength)
{
	U32 nCS = 0;
	
	for (; nLength; --nLength)
		nCS += *p++;
	return (U16)nCS;
}









 
static int GetAlStateBit(U32 code, U16 tn)
{


	










	
	return ((0x50 + 7) / 8) * 8 * tn + code - 0xE2000001;

}









 
int gt_alarm_state(U32 code, U16 tn)
{
	int bit = GetAlStateBit(code, tn);
	
	ChkAlarmState(bit / 8, 1);
	if ((alarm_state[bit / 8] & (1 << (bit % 8)))  != 0)
		return 1;
	else
		return 0;
}











 
static int gt_alstate_clr(U32 code, U16 tn, U32 file_lock)
{
	int bit, block;
	
	if (tn >= 1001)
		return 0;
	if (code > 0xE200004E || code < 0xE2000001)
		return 0;
	bit = GetAlStateBit(code, tn);
	if (ChkAlarmState(bit / 8, file_lock) != 1)
		return 0;
	gt_tsk_lock();	
	alarm_state[bit / 8] &= ~(1 << (bit % 8)) ;
	block = bit / 8 / 256;
	al_state_crc[block] = cs16(&alarm_state[block * 256], 256);
	gt_tsk_unlock();
	return 1;
}











 
static int gt_alstate_set(U32 code, U16 tn, U32 file_lock)
{
	int bit, block;
	
	if (tn >= 1001)
		return 0;
	if (code > 0xE200004E || code < 0xE2000001)
		return 0;
	bit = GetAlStateBit(code, tn);
	if (ChkAlarmState(bit / 8, file_lock) != 1)
		return 0;
	gt_tsk_lock();
	alarm_state[bit / 8] |= (1 << (bit % 8)) ;
	block = bit / 8 / 256;
	al_state_crc[block] = cs16(&alarm_state[block * 256], 256);
	gt_tsk_unlock();
	return 1;
}










 
int gt_alstate_save(U32 code, U16 tn, U32 state)
{
	int fp = 0;
	int offset;
	int ret = 0;
	
	if (tn >= 1001)
		return 0;
	if (code > 0xE200004E || code < 0xE2000001)
		return 0;
	if (AlarmFileLock(200) != 1)
		return 0;
	if (state)
		gt_alstate_set(code, tn, 0);
	else
		gt_alstate_clr(code, tn, 0);
	offset = GetAlStateBit(code, tn) / 8;
	fp = yaffs_io_open("alarm.bin", "r+");
	if (fp == 0)
		goto error;
	if (yaffs_io_seek(fp, offset + 16, 0) != 0)
	{

		if((debugMark & 1)==0)
		gt_printf("\nsave al state e1");

		goto error;
	}
	if (fs_io_write(&alarm_state[offset], 1, 1, fp) != 1)
	{

		if((debugMark & 1)==0)
		gt_printf("\nsave al state e2");

		goto error;
	}
	if (yaffs_io_close(fp) == 0)
		ret = 1;
error:
	AlarmFileUnlock();
	

	if((debugMark & 1)==0){
		if (ret == 0)
			gt_printf("\nsave al state err");
	}

	return ret;
}
	










 
static int ChkAlarmState(U32 offset, U32 file_lock)
{
	int fp;
	U32 i, ret = 0;
	U16 crc;
	
	i = offset / 256;
	crc = cs16(&alarm_state[i * 256], 256);
	if (crc == al_state_crc[i])
		return 1;

	if((debugMark & 1)==0)gt_printf("\nreload al state %d", i);

	if (file_lock)
	{
		if (AlarmFileLock(200) != 1)
			return 0;
	}
	fp = yaffs_io_open("alarm.bin", "r+");
	if (fp == 0)
		goto error;
	if (yaffs_io_seek(fp, i * 256 + 16, 0) != 0)
		goto error;
	if (fs_io_read(&alarm_state[i * 256], 1, 256, fp) != 256)
		goto error;
	gt_tsk_lock();
	al_state_crc[i] = cs16(&alarm_state[i * 256], 256);	
	gt_tsk_unlock();
	ret = yaffs_io_close(fp);	
	fp = 0;
error:	
	if (fp != 0)
		yaffs_io_close(fp);
	if (file_lock)
		AlarmFileUnlock();
	return ret;
}














 
static int ChkAlarm0Data(U32 id)
{
	int len;
	U32 code;
	U16 data;
	
	for (len = 0; len < alarm_0_len; )
	{
		memcpy(&code, &alarm_0_data[len], 4);
		if (code == id)
			return 1;
		len += 4;
		memcpy(&data, &alarm_0_data[len], 2);
		len += (2 + data);
	}
	return 0;
}










 
static int GetAlarm0Data(U32 id, void *dst, U32 size)
{
	int len;
	U32 code;
	U16 data;
	
	for (len = 0; len < alarm_0_len; )
	{
		memcpy(&code, &alarm_0_data[len], 4);
		if (code == id)
		{
			memcpy(dst, &alarm_0_data[len + 6], size);
			return size;
		}
		len += 4;
		memcpy(&data, &alarm_0_data[len], 2);
		len += (2 + data);
	}
	return 0;	


}









 
static SetAlarmInfo()
{
	gt_tsk_lock();
	alarm_happen = 1;
	gt_tsk_unlock();
}









 
int gt_alarm_info()
{
	return alarm_happen;
}









 
void gt_alarm_info_clr()
{
	alarm_happen = 0;
}
















 
static int OrganizeAlarmData(void *dst, const void *src, U32 src_len, U16 tn, U8 report, U32 code, void *index)
{
	char *buf = dst;
	char *index_buff = index;

	memcpy(index_buff, &code, 4);
	memcpy(index_buff + 4, &tn, 2);
	if (report)
	{
		index_buff[6] = 3;
		index_buff[7] = 0;	
	}
	else
	{
		index_buff[6] = 0;
		index_buff[7] = 'n';	
	}	
	
	memset(buf, 0xFF, 16);
	memcpy(buf, &src_len, 2);
	memcpy(&buf[2], &tn, 2);
	if (report)	
		buf[4] = 3;
	else
		buf[4] = 0;
	if (report == 0)
		buf[5] = 'n';
	else
		buf[5] = 0;				
	memcpy(buf + 16, &code, 4);	
	memcpy(buf + 16 + 4, src, src_len);
	return src_len + 16 + 4;
}













 
int gt_alarm_write(U32 code, U16 tn, void *src, U32 len)
{
	int fp = 0;
	char *buf = al_buff;
	U32 offset;
	U16 total_num, new_num, unreport_num;
	char mask[32], index_buff[10], report = 0;
	

	if((debugMark & 1)==0)gt_printf("\r\nalarm: %X, tn: %d, %X", code, tn, *(U8 *)src);

	if (len == 0 || len > (512 - 16))
		return 0;
	if (tn > 1001)
		return 0;
	gt_para_process(0, 0xE0000151, (U8 *)mask, 32, 'r', 0);
	if (GetBit(mask, code - 0xE2000001) == 0)
		return 0;
	
	if (AlarmFileLock(200) != 1)
	{

		if((debugMark & 1)==0)gt_printf("\r\nsave lock al fail");

		return 0;
	}
	memcpy(&report, src, 1);
	switch (report)
	{
		case 0:
			gt_alstate_clr(code, tn, 0);
			break;
		case 1:
			gt_alstate_set(code, tn, 0);
			break;
		default:
			break;
	}
	fp = yaffs_io_open("alarm.bin", "r+");
	if (fp == 0)
	{

			if((debugMark & 1)==0)gt_printf("\nsave al open err");

			goto al_error;			
	}
	else
	{
		if (fs_io_read(buf, 1, 16, fp) != 16)
		{

			if((debugMark & 1)==0)gt_printf("\nsave al read err");

			goto al_error;	
		}
	}

	memcpy(&total_num, buf, 2);
    if (total_num < 400)
		total_num++;	
	memcpy(&new_num, buf + 2, 2);
	if (++new_num > 400)
		new_num	= 1;
	memcpy(&unreport_num, buf + 4, 2);
	if (gt_para_process(0, 0xE0000150, (U8 *)mask, 32, 'r', 0) != 32)
		memset(mask, 0xFF, 32);
	if ((mask[(code - 0xE2000001) / 8] & (1 << ((code - 0xE2000001) % 8))) != 0)
	{
		report = 1;	
		unreport_num++;
	}
	
	
	len = OrganizeAlarmData(buf, src, len, tn, report, code, index_buff);
	if (yaffs_io_seek(fp, (16 + (1001 * ((0x50 + 7) / 8)) + (400 * 8)) + (new_num - 1)* 512, 0) != 0)
	{

	   	if((debugMark & 1)==0)gt_printf("\nerror");

		goto al_error;
	}
	else
	{	
		if (fs_io_write(buf, 1, len, fp) != len)
		{

			if((debugMark & 1)==0)gt_printf("\nerror");

			goto al_error;
		}
	}
	
	if (yaffs_io_close(fp) != 0)
		goto al_error;
	fp = yaffs_io_open("alarm.bin", "r+");
	if (fp == 0)
		goto al_error;	
	if (yaffs_io_seek(fp, (16 + (1001 * ((0x50 + 7) / 8))) + (new_num - 1)* 8, 0) != 0)	
	{

	   	if((debugMark & 1)==0)gt_printf("\r\nerror");

		goto al_error;
	}	
	if (fs_io_write(index_buff, 1, 8, fp) != 8)
	{

		if((debugMark & 1)==0)gt_printf("\r\nerror");

		goto al_error;
	}	
	
	
	if (yaffs_io_close(fp) != 0)
		goto al_error;
	fp = yaffs_io_open("alarm.bin", "r+");
	if (fp == 0)
		goto al_error;
	memcpy(buf, &total_num, 2);
	memcpy(buf + 2, &new_num, 2);
	memcpy(buf + 4, &unreport_num, 2);
	if (fs_io_write(buf, 1, 16, fp) != 16)
	{

	   if((debugMark & 1)==0)	gt_printf("\r\nerror");

		goto al_error;		
	}
	yaffs_io_close(fp);
	
	fp = yaffs_io_open("alarm.bin", "r+");
	if (fp == 0)
		goto al_error;
	offset = GetAlStateBit(code, tn) / 8;
	if (yaffs_io_seek(fp, offset + 16, 0) != 0)
		goto al_error;
	if (fs_io_write(&alarm_state[offset], 1, 1, fp) != 1)
		goto al_error;	
	report = yaffs_io_close(fp);

	

	AlarmFileUnlock();
	
	if (report == 0)
	{
		SetAlarmInfo();
		

		if((debugMark & 1)==0)gt_printf("\r\nindex %d", new_num);

		return new_num;
	}
	return 0;

al_error:

	if((debugMark & 1)==0)gt_printf("\r\nsave alarm error");

	if (fp != 0)
		yaffs_io_close(fp);
	AlarmFileUnlock();
	return 0;	
}

 












 
static int AlarmSave(U32 seq, U16 tn, U32 state, U32 time)
{
	extern int report_add(uint16 sno,uint32 di,uint8* dat,int size, int index);
	struct tm t;
	t_sysTable info;
	int len, i;
	
	if (seq >= 0xE2000001)
	{
		for (i = 0; i < sizeof(alarm_list) / sizeof(alarm_list[0]); i++)
		{
			if (alarm_list[i].code == seq)
				break;
		}
		if (i >= sizeof(alarm_list) / sizeof(alarm_list[0]))
			return 0;
		seq = i;
	}	
	




	alarm_buff[0] = state;
	len = time;			
	localtime_r(&len, &t);
	alarm_buff[1] = bin2bcd8(t.tm_sec);
	alarm_buff[2] = bin2bcd8(t.tm_min);	
	alarm_buff[3] = bin2bcd8(t.tm_hour);	
	alarm_buff[4] = bin2bcd8(t.tm_mday);	
	alarm_buff[5] = bin2bcd8(t.tm_mon + 1);	
	alarm_buff[6] = bin2bcd8(t.tm_year - 100);	
	len = 7;	
	if (alarm_list[seq].item_num != 0)
	{
		for (i = 0; i < alarm_list[seq].item_num; i++)
		{
			if (alarm_list[seq].list[i].id == 0xE0000130)
			{
				memcpy(&alarm_buff[len], &alarm_buff[1], 6);
				len += 6;
				continue;
			}
			if (gt_para_getIndex(tn, alarm_list[seq]. list[i]. id, &info) != 1)
			{

				if((debugMark & 1)==0)gt_printf("\nal tn%d : %08X", tn, alarm_list[seq].list[i].id);

				continue;
			}
			if (alarm_list[seq].list[i].data_time == 0)
				len += GetAlarm0Data(alarm_list[seq].list[i].id, &alarm_buff[len], info.size);
			else
			{
				
				gt_grup_process (tn, alarm_list[seq].list[i].id, info.gat, &alarm_buff[len], info.size, 'r', 0);
				len += info.size;
			}
		}
	}











	i = gt_alarm_write(alarm_list[seq].code, tn, alarm_buff, len);


	return i;
}












 
int gt_alarm_save(U32 seq, U16 tn, U32 state)
{
	return AlarmSave(seq, tn, state, time(0));
}

 











 
int gt_alarm_save_t(U32 seq, U16 tn, U32 state, time_t t)
{
	return AlarmSave(seq, tn, state, t);
}










 
static int CreateAlarmFile()
{
	int fp = 0;
	int ret= 0;
	int i, max;

	fp = yaffs_io_open("alarm.bin", "w");
	if (fp != 0)
	{
		memset(al_buff, 0, 16);				
		if (fs_io_write(al_buff, 1, 16, fp) != 16)
		{

			if((debugMark & 1)==0)gt_printf("\ncreate al f1");

			yaffs_io_close(fp);
			fs_io_unlink("alarm.bin");
			return 0;
		}
		memset(alarm_state, 0, (1001 * ((0x50 + 7) / 8)));
		if (fs_io_write(alarm_state, 1, (1001 * ((0x50 + 7) / 8)), fp) != (1001 * ((0x50 + 7) / 8)))
		{

			if((debugMark & 1)==0)gt_printf("\ncreate al f2");

			yaffs_io_close(fp);
			fs_io_unlink("alarm.bin");
			return 0;
		}
		memset(al_buff, 0xFF, 10 * 512);
		if (fs_io_write(al_buff, 1, (400 * 8), fp) != (400 * 8))
		{
			yaffs_io_close(fp);
			return 0;
		}
		max = 400 + 10 - 1;
		for (i = 0; i <= max; i += 10)
		{
			if (fs_io_write(al_buff, 1, 10 * 512, fp) != 10 * 512)
			{

				if((debugMark & 1)==0)gt_printf("\ncreate al f-%d", i);

				break;
			}
		}
		if (i > max)
			ret = 1;
		if (yaffs_io_close(fp) == 0)
			return ret;
	}
	return 0;
}












 
int gt_alarm_init()
{
	int fp = 0;
	int ret= 0, i;
	
	if (AlarmFileLock(200) != 1)
		return 0;
	memset(alarm_state, 0, 21 * 1001 / 8);
	fp = yaffs_io_open("alarm.bin", "r");
	if (fp == 0)
	{
		ret = CreateAlarmFile();
	}
	else
	{
		if (yaffs_io_seek(fp, 16, 0) == 0)
		{	
			if (fs_io_read(alarm_state, 1, (1001 * ((0x50 + 7) / 8)), fp) != (1001 * ((0x50 + 7) / 8)))
				gt_printf("\ninit read alarm state err");
			else
			{
				for (i = 0; i < ((1001 * ((0x50 + 7) / 8)) + 256 - 1) / 256; i++)
				{
					al_state_crc[i] = cs16(&alarm_state[i * 256], 256);
				}
			}
		}
		else
			gt_printf("\ninit read state e2");
		yaffs_io_close(fp);
		ret = 1;
	}
	AlarmFileUnlock();
	return ret;
}
















 
int gt_alarm_read(U32 code, U16 tn, U32 index, void *dst, int *len, int for_report, int *report_count) 
{
	int fp = 0;
	alarm_index_type *info, info_index;
	U16 total, read_num, count, j, num_per_time, offset;
	int find; 
	int err = 0;
	U16 read_len, unreport;
	char *buff;

	if (index == 0)
		return 0;

	buff = al_buff;





	if (AlarmFileLock(200) != 1)
	{

	 	if((debugMark & 1)==0)gt_printf("\nread lock al failed");




		return 0;
	}
	fp = yaffs_io_open("alarm.bin", "r+");
	if (fp == 0)
	{

	 	if((debugMark & 1)==0)gt_printf("\nopen al failed");

		goto read_ret;
	}
	if (fs_io_read(buff, 1, 6, fp) != 6)
	{

	 	if((debugMark & 1)==0)gt_printf("\nread al e1");

		goto read_ret;	
	}
	memcpy(&total, buff, 2);
	memcpy(&read_num, buff + 2, 2);	
	memcpy(&unreport, buff + 4, 2);
	count = 0;
	if (total < index)
	{
		goto read_ret;
	}
	
	if (code == 0xE200FFFF)
		code = 0xFFFFFFFF;

	count = 0;
	find = 0;
	while (count < total)
	{
		if (read_num > 10 * 512 / 8)
		{
			num_per_time = 10 * 512 / 8;
			offset = read_num - num_per_time;			
			read_num -= num_per_time;
		}
		else
		{
			num_per_time = read_num;
			offset = 0;
			read_num = total;
		}
		count += num_per_time;
		if (yaffs_io_seek(fp, (16 + (1001 * ((0x50 + 7) / 8))) + offset * 8, 0) != 0)
		{			

			if((debugMark & 1)==0)gt_printf("\nfseek al e4");

			break;			
		}
		if (fs_io_read(buff, 1, num_per_time * 8, fp) != num_per_time * 8)
		{			

			if((debugMark & 1)==0)gt_printf("\nread al e5");

			break;			
		}	

		for (j = num_per_time; j > 0; j--)
		{
			info = (alarm_index_type *)(buff + (j - 1) * 8);
			if (code == 0xE20010FF)
			{				
				if ((info->report == 0) && (info->confirm == 0))
					find++; 		
			}
			else  
			{	
				if (for_report == 1)
				{
					if ((info->report == 0) || (info->confirm == 'n') || (info->confirm == 1))
						continue;
				}	
				if ((code == 0xFFFFFFFF) && (tn == 0xFFFF))			
					find++;
				else if ((code == 0xFFFFFFFF) && (tn != 0xFFFF))			
				{
					if (info->tn == tn)
						find++;
				}
				else if ((code != 0xFFFFFFFF) && (tn == 0xFFFF))	
				{
					if (info->code == code)
						find++;
				}	
				else												
				{
					if ((info->code == code) && (info->tn == tn))		
						find++;
				}
			}
			if (find == index)
			{		
				memcpy(&info_index, buff + (j - 1) * 8, sizeof(alarm_index_type));
				info = &info_index;
				err = offset + j; 		
				break;
			}	
		}
		if (err > 0)
			break;
	}
	
	if (err)
	{
		if (yaffs_io_seek(fp, (16 + (1001 * ((0x50 + 7) / 8)) + (400 * 8)) + (err - 1) * 512, 0) != 0)
			err = 0;
		else
		{
			if (fs_io_read(buff, 1, 512, fp) == 512)
			{
				read_len = 0;
				memcpy(&read_len, buff, 2);
				read_len += 6;
				if (read_len  > *len)
					read_len = *len;
				memcpy(dst, buff + 2, 2);
				memcpy((char *)dst + 2, buff + 16, read_len - 2);
				*len = read_len;					
				if (for_report == 1)
				{
					if (yaffs_io_seek(fp, (16 + (1001 * ((0x50 + 7) / 8))) + (err - 1) * 8 + 6, 0) == 0)
					{
						if (info->report)
							info->report--;
						fs_io_write(&info->report, 1, 1, fp);				
					}
				}
			}
			else
				err = 0;
		}	
	}
	
read_ret:
	if (fp != 0)
		yaffs_io_close(fp);	
	AlarmFileUnlock();		



	return err;		
}














 
int gt_alarm_total(U32 code, U16 tn, U32 *for_report)
{
	int fp = 0;
	U16 total, read_num, i;
	int count, per_time;
	int read_code; 
	U16 read_tn;
	char buff[40];

	if (AlarmFileLock(200) != 1)
		return -1;
	fp = yaffs_io_open("alarm.bin", "r+");
	if (fp == 0)
	{

	 	if((debugMark & 1)==0)gt_printf("\nopen al fail");

		
		AlarmFileUnlock();
		return -1;
	}
	if (fs_io_read(buff, 1, 6, fp) != 6)
	{

	 	if((debugMark & 1)==0)gt_printf("\nread al error");

		count = -1;
		goto ret;	
	}
	memcpy(&total, buff, 2);
	memcpy(&read_num, buff + 2, 2);	
	count = 0;
	*for_report = 0;
	
	if (code == 0xE200FFFF)
		code = 0xFFFFFFFF;
	if ((code == 0xFFFFFFFF) && (tn == 0xFFFF))			
	{
		memcpy(&count, buff + 4, 2);
		*for_report = count;
		count = total;
		
	}
	else
	{
		count = 0;
		per_time = 10 * 512 / 8;		
		if (yaffs_io_seek(fp, (16 + (1001 * ((0x50 + 7) / 8))), 0) != 0)	
		{
			count = -1;
			goto ret;
		}
		for (; total > 0; total -= per_time)
		{
			if (total < per_time)
				per_time = total;	
			if (fs_io_read(al_buff, 1, per_time * 8, fp) != per_time * 8)
			{		

				if((debugMark & 1)==0)gt_printf("\nal total err");

				count = -1;
				goto ret;
			}
			for (i = 0; i < per_time; i++)
			{
				memcpy(&read_code, &al_buff[8 * i], 4);
				memcpy(&read_tn, &al_buff[8 * i + 4], 2);
				if ((code == 0xFFFFFFFF) && (tn != 0xFFFF))			
				{
					if (tn == read_tn)
						count++;
				}
				else if ((code != 0xFFFFFFFF) && (tn == 0xFFFF))	
				{
					if (code == read_code)
						count++;
				}	
				else												
				{
					if ((read_code == code) && (read_tn == tn))		
						count++;
				}
			}
		}

	}
ret:
	yaffs_io_close(fp);
	AlarmFileUnlock();
	return count;
}









 
int gt_alarm_report()
{
	extern int report_add(uint16 sno,uint32 di,uint8* dat,int size, int index);
	U8 buff[512];
	U32 len = 512 - 3, ct, index, code, i;
	U16 tn;
	
	i = 1;
	while (1)
	{
		if ((gt_netlog_state() != 0x08) && (gt_netlog_state() != 0x02))
			return 0;
		if (gt_net_step() != 0x23)
			return 0;
		if (report_chk() != 1)
			return 0;
		len = 512 - 3;
		index = gt_alarm_read(0xFFFFFFFF, 0xFFFF, i++, buff, &len, 1, &ct);
		if (index > 0)
		{
			memcpy(&tn, buff, 2);
			memcpy(&code, (U8 *)buff + 2, 4);
			memmove(buff, (U8 *)buff + 6, len - 6);
			if (report_add(tn, code, buff, len - 6, index) == 0)
				break;
		}
		else
			break; 
	}
	return 0;
}









 
int gt_alarm_clear()
{	
	int ret = 0;
	
	if (AlarmFileLock(200) != 1)
		return 0;

	if((debugMark & 1)==0)gt_printf("\nclear al file");

	if (fs_io_unlink("alarm.bin") == 0)
	{
		ret = CreateAlarmFile();
	}
	AlarmFileUnlock();
	return ret;
}










 
int gt_alarm_confirm(U32 index)
{
	int fp = 0;

	int ret = 0;
	int temp; 


	if((debugMark & 1)==0)gt_printf("\nconfirm al %d", index);

	
	if ((index == 0) || (index > 400))
		return 0;
	if (AlarmFileLock(200) != 1)
	{
		return 0;
	}
	fp = yaffs_io_open("alarm.bin", "r+");
	if (fp == 0)
	{

	 	if((debugMark & 1)==0)gt_printf("\nconfirm al error1");

		goto confirm_ret;
	}
	if (yaffs_io_seek(fp, (16 + (1001 * ((0x50 + 7) / 8))) + (index - 1) * 8 + 7, 0) != 0)
	{

	 	if((debugMark & 1)==0)gt_printf("\nconfirm al error2");

		goto confirm_ret;
	}		
	temp = 1;
	if (fs_io_write(&temp, 1, 1, fp) == 1)
		ret = 1;
	else
		ret = 0;
	





































confirm_ret:	
	if (fp != 0)
		yaffs_io_close(fp);
	AlarmFileUnlock();	
	return ret;
}










 
int gt_alarm_size()
{
	int fp = 0;
	int size;
	
	fp = yaffs_io_open("alarm.bin", "r");
	if (fp == 0)
	{
		gt_printf("\nno al file");
		return -1;
	}
	size = fs_io_size(fp);
	yaffs_io_close(fp);
	return size;
}









 
static int MeterDataNew(U16 tn)
{
	U32 meter;
	U32 now = time(0);
	
	if (gt_para_process(tn, 0xF1000000, (U8 *)&meter, 4, 'r', 0) != 4)
		return 0;
	if (now < meter)
		return 0;
	if (now - meter < 10)
		return 1;
	return 0;
}











 
static void InitAlCmpData()
{
	alarm_cmp_len = 0;
	memset(alarm_cmp, 0, sizeof(alarm_cmp));
}










 
static int SaveAlCmpData(U16 tn, U32 id)
{
	t_sysTable info;
	char temp[100];
	
	gt_para_getIndex(tn, id, &info);
	if (gt_para_process(tn, id, (U8 *)temp, info . size, 'r', 0) != info.size)
		return 0;
	memcpy(&alarm_cmp[alarm_cmp_len], &id, 4);
	alarm_cmp_len += 4;
	alarm_cmp[alarm_cmp_len++] = info.size;
	memcpy(&alarm_cmp[alarm_cmp_len], temp, info.size);
	alarm_cmp_len += info.size;

	if((debugMark & 1)==0){
	if (alarm_cmp_len > 10240)
		gt_printf("\nalarm_cmp if too small: %d", alarm_cmp_len);
		}

	return 1;
}










 
int GetAlarmCmpData(U16 tn, U32 id, void *dst)
{
	U32 p;
	U32 code, len;
	
	for (p = 0; p < alarm_cmp_len; )
	{
		memcpy(&code, &alarm_cmp[p], 4);
		p += 4;
		len = alarm_cmp[p++];
		if (code != id)
		{
			p += len;
			continue;
		}
		memcpy(dst, &alarm_cmp[p], len);
		return 1;
	}
	return 0;
}












 
int gt_alarm_handler(U16 tn, U32 type, U32 step)
{
	t_sysTable info;
	int i, j, k, run;
	int state, exe, ret;
	char temp[32];
	U8 mask[32];
	static U32 init = 0x38732562;
	static U8 first_read[128] = {0};
	
	if (type < 1 && type > 3)
		return 0;	
	if (init == 0x38732562)
	{
		memset(meter_fail, 0, sizeof(meter_fail));
	}	
	init = 0;
	
	memset(alarm_0_data, 0, 500);
	alarm_0_len = 0;
	if (step == 1)
	{
		if (MeterDataNew(tn) != 1)
		{
			bitClr((uint32*)(first_read),(tn));
			return 0;	
		}
		



















































 
		
	}
	else
		InitAlCmpData();
	gt_para_process(0, 0xE0000151, (U8 *)mask, 32, 'r', 0);
	
	if (step == 1)
	{
		if (GetBit(first_read, tn) == 0)
		{
			bitSet((uint32*)(first_read),(tn));
			return 0;
		}
	}
	


	
	for (i = 0; i < 21; i++)
	{

		gt_tsk_deamon();
		
		if (alarm_list[i].code < 0xE2000001 || alarm_list[i].code > 0xE200004E)
			continue;
		run = 0;
		switch (type)
		{
			case 1:
				if (alarm_list[i].total == 1)
					run = 1;
				break;
			case 2:
				if (alarm_list[i].single == 1)
					run = 1;
				break;				
			case 3:
				if (alarm_list[i].three == 1)
					run = 1;
				break;					
			default:
				break;
		}
		if (run == 0)
			continue;
		if (GetBit(mask, alarm_list[i].code - 0xE2000001) == 0)
			continue;
		
		ret = 0xFF;
		switch (step)
		{
			case 0:
				for (j = 0; j < alarm_list[i].item_num; j++)
				{
					if (alarm_list[i].list[j].data_time == 0)
					{
						if (gt_para_getIndex(tn, alarm_list[i]. list[j]. id, &info) != 1)
							continue;
						if (ChkAlarm0Data(alarm_list[i].list[j].id) == 1)
							continue;
						memcpy(&alarm_0_data[alarm_0_len], &alarm_list[i].list[j].id, 4);
						alarm_0_len += 4;
						memcpy(&alarm_0_data[alarm_0_len], &info.size, 2);
						alarm_0_len += 2;
						
						gt_grup_process(tn, alarm_list[i].list[j].id, info.gat, &alarm_0_data[alarm_0_len], info.size, 'r', 0);
						alarm_0_len += info.size;
					}
				}
				if (alarm_list[i].id_num == 0)
					break;
				
				for (k = 0; k < alarm_list[i].id_num; k++)
				{




					SaveAlCmpData(tn, alarm_list[i].judge_id[k]);
				}
				break;
			
			case 1:		
				state = gt_alarm_state(alarm_list[i].code, tn);
				if (alarm_list[i].id_num == 1 && alarm_list[i].judge_func == 0)	
				{
					if (gt_para_getIndex(tn, alarm_list[i]. judge_id[0], &info) != 1)
						break;				
					gt_para_process(tn, alarm_list[i]. judge_id[0], (U8 *)temp, info . size, 'r', 0);
					if (memcmp(temp, &alarm_cmp[i], info.size) != 0)
						ret = 1;
					else
					{
						if (state == 1)
							ret = 0;
					}	
				}		
				else 
				{
					if (alarm_list[i].judge_func == 0)
						break;							
					exe = (*alarm_list[i].judge_func)(tn, state, type, 0);				
					if (exe == 0xFF)
						break;
					if (state == 0)			
					{
						if (exe == 0)
							continue;
						ret = 1;
					}
					else
					{
						if (exe == 1)
							continue;
						ret = 0;
					}
				}
				break;
				
			default:
				break;
		}
		
		switch (ret)
		{
			case 0:
				if ((alarm_list[i].state == 1) && (tn < 9))
					gt_alarm_save(i, tn, 0);
				else 
					gt_alstate_save(alarm_list[i].code, tn, 0);	
				if (alarm_list[i].undo_action != 0)
					(*alarm_list[i].undo_action)(tn, type);	
				break;
			
			case 1:
				gt_alarm_save(i, tn, 1);
				if (alarm_list[i].action != 0)
					(*alarm_list[i].action)(tn, type);
				break;
			
			default:
				break;
		}
		
	}
	return 1;
}




 




